Storing vectors for different time steps in same variable name

2 次查看(过去 30 天)
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 ?

采纳的回答

KL
KL 2017-11-7
编辑:KL 2017-11-7
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by