Is there a way to force Simulink to treat a 3x3x1 matrix as 3D instead of a 2D 3x3 matrix?

2 vues (au cours des 30 derniers jours)
I have a portion of code that sizes a matrix x as 3x3xn, where n can vary between simulations. If I have n>1 I can index values as y1 = x(:,:,1), y2 = x(:,:,2) and so on. If n = 1, then x is rtated as a 3x3 matrixand indexing x(:,:,1) produces an index out of bounds error because there is no third dimension. Is there a way to force x to always have three dimensions?

Réponses (1)

Siriniharika Katukam
Siriniharika Katukam le 18 Fév 2020
Hi
I tried the following code and didn’t find any error.
x = rand(3,3,1);
x(:,:,1);
if you try accessing x(:,:,2), then only you get the error you encountered.

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by