how to plot results ?

Hello,
I am running for loop and saving results from error to e1{1}.... for each iteration.
but i want to plot the results. how should i do this ? is this correct method of saving results?
*******************************
for p=1:3
for q = 1:50
v = ['w', num2str(q),'(2,end)'];
w(q) = eval(v);
end
sim('with50osc.mdl')
e2{1}=error;
e3{2}=error;
e4{3}=error;
end
****************************************

 採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 12 日

0 投票

7 件のコメント

Aniket
Aniket 2013 年 3 月 12 日
Hello i have seen you link but i am doing simulations in simulink saving my results as an array in "error" variable and for each iteration i want to get the results as saved in "e" so i can plot results for iteration 1,2,3...
Walter Roberson
Walter Roberson 2013 年 3 月 12 日
You should not be constructing your "w" in that manner.
After your "sim" use
e{p} = error;
However, I cannot tell you how to plot after the loop until you say more about what "error" will look like. Is it a scalar? A vector? A structure?
Walter Roberson
Walter Roberson 2013 年 3 月 12 日
You note in your duplicate that
and the results are storing as following way
< 25627*2 double > [ ] [ ] [ ]
so your simulation does not appear to be defining a useful error result for the other iterations.
It is not clear why you would want to simulate the same system 4 different times?
How do you want that 25627*2 to be plotted ?
Aniket
Aniket 2013 年 3 月 12 日
error is from simulink scope results that is an array of vector < 25646x2 double>
1 coloumn is time and 1 coloumn is data
Aniket
Aniket 2013 年 3 月 12 日
no its an pool of oscillators and first time i am defining initial conditions and for second time initial conditions are final values of first simulation like i have to do for 4 time ...so i can get a better results and thats why i want to save and plot first iteration values , second iteration values .... upto 4 times and compare it
Walter Roberson
Walter Roberson 2013 年 3 月 12 日
colors = {'r', 'g', 'c', 'b'}; %color for traces
for K = 1 : length(e)
plot(e{K}(:,1), e{K}(:,2), colors{K} );
hold on
end
Aniket
Aniket 2013 年 3 月 12 日
Thanks for this its working

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by