Simulink from workspace block

1 view (last 30 days)
Hello,
I am new to using simulink and not sure how it works entirely. I am trying to do a simple task of passing values in real time to simulink. I want my data from my for loop to be passed into simulink and displayed there.
My issue is that not all vector values are being transfered to simulink.
My code is:
x = ones(1,5);
n = 5;
for i = 1:n
angles = randi([0 180], [1 5]);
data = angles;
sim('ardsim2013');
end
('ardsim2013' is the simulink file and only has the "From workspace" source block and leads into "Display" block)
I am trying to pass the angles vector into simulink however the first number from "angles" gets cut off when passed into simulink and the display block reads only 4 values instead of 5.
i.e. I want
angles = [1 2 3 4 5]
to be passed into simulink but
angles = [2 3 4 5]
are the only values that are displayed and passed into simulink.
How can I fix this so that the whole vector is passed?
Thank you.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 5 Oct 2020
When the data specified in the FromWorkspace block is an array, the first column is the time, so your data means that at time=1 seconds, your provided 4 values which is [2 3 4 5].
By the way, using for-loop for "passing values in real time to simulink" like you did is not practical. Please figure out FromWorkspace block first and describe what you want in a different question.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2013a

Community Treasure Hunt

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

Start Hunting!