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
****************************************

 Risposta accettata

Walter Roberson
Walter Roberson il 12 Mar 2013

0 voti

7 Commenti

Aniket
Aniket il 12 Mar 2013
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...
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?
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 il 12 Mar 2013
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 il 12 Mar 2013
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
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 il 12 Mar 2013
Thanks for this its working

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Simulink in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by