3D Matrix in Simulink which can be 2D is not supported

355 views Asked by At

I am using SIMULINK and I needed to define a Rotation Matrix 3,3,N where N is the number of Robots which I am trying to simulate. To do that, because I am also using the Simulink Coder I had to define the signal related to this matrix as Variable Size and I had to define the upper-bound in the following way: enter image description here

The problem is that when I want to use only one robot (I set n_robots to 1) I get the following error.

Cannot initialize dimensions of 'R' of 'test_pos_ctrl_target/rotation matrix to Euler angles' to [3x3x1]. When the number of dimensions of a matrix exceeds 2, the size of the trailing dimension must be greater than 1.

Someone could help me?

thanks a lot.

1

There are 1 answers

0
am304 On BEST ANSWER

You can't have the last dimension as 1 because MATLAB treats any matrix of dimension [m,n,1] as [m,n]. See size() returns 1 where matrix dimension should not exist for more details.

Try defining R of size [n_robots,3,3] and then re-arrange the matrix inside your code (I assume you are using a MATLAB Function block).