MATLAB Answers

uzmeed
0

converting a vector input to scalar

Asked by uzmeed
on 4 Dec 2019 at 18:39
Latest activity Edited by Ridwan Alam on 5 Dec 2019 at 0:36
Hi
I have a 3x3 matrix input.
I assign it to some variables to make 7x1 variable (appending zeros)
I need to use it in simulink
Now from each column when i read data through workspaceI get only last value at the result but not the rest first 2
My code is as under
Test_data=[dummy_left(x,:);dummy_data(x,:);dummy_right(x,:)]
A_I=[0;Test_data(:,1);0;0;0]
B_I=[0;Test_data(:,2);0;0;0];
C_I=[0;Test_data(:,3);0;0;0];
for i=1:4
A=A_I(i,:);
B=B_I(i,:);
C=C_I(i,:);
end

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Ridwan Alam on 4 Dec 2019 at 18:47

You are assinging different values to A,B, and C in every iteration of the for loop. That's why you are left with the last assigned value. Also, looks like your A_I, B_I, C_I are vectors, not matrices. So no need to use A_I(i,:), just use A_I(i), maybe? What's the purpose the for loop?

  2 Comments

Guillaume
on 4 Dec 2019 at 19:19
uzmeed's comment mistakenly posted as an answer moved here:
Yes you are wrire I am assigning different value at each iteration
because I want that the code should output different values at different time instances
This program is the input to a FPGA IP
Purpose of the loop is to convert vector to scalar and stream the output data in time domain
Ridwan Alam on 5 Dec 2019 at 0:34
Okay ... so you want to see the A,B,C values for each iteration i? If that's the case, try using disp() or pause() or delay() inside the loop, or simply remove the line-ending ';' inside the loop.

Sign in to comment.