Storing vectors for different time steps in same variable name
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sudharsan Srinivasan
am 7 Nov. 2017
Kommentiert: Sudharsan Srinivasan
am 9 Nov. 2017
I have a vector A of size 30 by 1, which changes its value for every time steps (ts). How will I store all the values in a same variable name say 'b' ? After storing I have to plot all its changes in single command. How can I do it ?
0 Kommentare
Akzeptierte Antwort
KL
am 7 Nov. 2017
Bearbeitet: KL
am 7 Nov. 2017
Why don't you use a matrix?
Let's say you have 10 timesteps (1 to 10),
ts = 1:10;
so now you'll need to track A's changes during every timestep. So create a 30x11 matrix and the first column being A's initial values.
A = zeros(30,11);
fill first column with initial values,
A(:,1) = rand(30,1);
now do something which changes this first column during every timestep,
for k=1:numel(ts)
A(:,k+1) = rand*A(:,1); %or even A(:,k+1) = rand*A(:,k);
end
now plot all changes,
plot(A)
you'll see 11 curves each for a timestep plus initial states.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!