フィルターのクリア

Storing vectors for different time steps in same variable name

2 ビュー (過去 30 日間)
Sudharsan Srinivasan
Sudharsan Srinivasan 2017 年 11 月 7 日
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 Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by