Reputation: 2980
I have a MATLAB function block embedded in a Simulink model. In my initFnc callback I set up some vectors which I need to use in my function block inside the simulink model. The vector is 1x10000 and contains setpoints for a robotic arm. The function block simply needs to read the next value at each sample iteration.
So far I've tried using "From Workspace" and "evalin()" but they all throw various errors when building the model (I'm using code generation which doesn't play nice all the time).
What would be a good way to read in that vector in Simulink and feed the cells one by one into my function block? Something like repeating sequence stair but without the repeating part.
Upvotes: 0
Views: 1695
Reputation: 2980
I got it to work by reading in the vector into a constant block and feeding that into my embedded function. I then use a persistent iterator which is a 1x1 matrix (ones(1)
) and incrementing it every time the value from the vector is read.
Upvotes: 0