DMD
DMD

Reputation: 43

How to use multidimensional constant array in for iterator block in matlab/simulink?

I have an array (300x6) and I want to use it for this block in simulink. But I have a problem. How can I use "for iterator" block to take the q(i,:), q(i+1,:) , q(i+2,:) ... elements respectively? Or is there any other way to do this idea? Thanks.

enter image description here


enter image description here

Upvotes: 0

Views: 2054

Answers (1)

Luis Mendo
Luis Mendo

Reputation: 112659

In Matlab, for iterates over matrix columns. So you can just transpose to iterate over rows:

A = [1 2 3; 4 5 6; 7 8 9]; %// example matrix
for v = A.'
    v = v.'; %// v will be [1 2 3], then [4 5 6] etc
    %// Do stuff with v
end

I'm not into Simulink but I guess you can adapt this to that environment.

Upvotes: 1

Related Questions