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

 Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Mzo. de 2013

0 votos

7 comentarios

Aniket
Aniket el 12 de Mzo. de 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...
Walter Roberson
Walter Roberson el 12 de Mzo. de 2013
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 el 12 de Mzo. de 2013
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 el 12 de Mzo. de 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 el 12 de Mzo. de 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
Walter Roberson
Walter Roberson el 12 de Mzo. de 2013
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 el 12 de Mzo. de 2013
Thanks for this its working

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by