How to plot different length vectors

3 vues (au cours des 30 derniers jours)
Felix Lauwaert
Felix Lauwaert le 16 Juil 2015
Commenté : Walter Roberson le 16 Juil 2015
Hi,
I need to plot different orbits in one figure.
The coordinate vectors are result of a Runge-Kutta 7-8 so I can't know if the number of elements from each orbit coordinates are the same (maybe one has 2000 points and another 2500 or so.
When I try to plot them all together, the result is that I get only the last figure.
My code is:
C=C1;
[ resu1 ] = nInt( fun , ab , tspan, titol, rotulacio,C );
C=C2;
[ resu2 ] = nInt( fun , ab , tspan, titol, rotulacio,C );
C=C3;
[ resu3 ] = nInt( fun , ab , tspan, titol, rotulacio,C );
rD1=resu1(2,:)./d;
rpD1=resu1(4,:)./d;
rD2=resu2(2,:)./d;
rpD2=resu2(4,:)./d;
rD3=resu3(2,:)./d;
rpD3=resu3(4,:)./d;
plot (rD1,rpD1,rD2,rpD2,rD3,rpD3)
title('rp/d vs r/d');
xlabel('r/d');
ylabel('rp/d');
I just get rD3 vs rpD3. Where is my mistake?
Thanks.

Réponse acceptée

Walter Roberson
Walter Roberson le 16 Juil 2015
When you plot() multiple pairs of values and your plot appears to have only a single output, then one possibility is that your lines are all the same to within drawing scale, that the lines are right on top of each other to within the resolution of the screen.
Sometimes zooming in can show the differences between the lines. Sometimes using different markers for the lines can help show that they are all there. Sometimes using different line styles can help (e.g., a solid line would be visible in the gaps of a dashed line)
For testing purposes, try
subplot(1,3,1)
plot(rD1,rpD1)
subplot(1,3,2)
plot(rD2,rpD2)
subplot(1,3,3)
plot(rD3,rpD3)
if all three lines appear and have the same shape then they would have been on top of each other with the single plot() call.
  4 commentaires
Felix Lauwaert
Felix Lauwaert le 16 Juil 2015
C1 C2 and C3 are provided by me, they're different values (4.8e4, 4.9e4 and 7e4) and nInt is a tested script it works correctly. It executes the runge-kutta 7-8 subroutine which is also proven correct. I attatched two plots which are different (see right side, they get different x-axis values. Those are plotted as the same when I put them in the same figure.
Walter Roberson
Walter Roberson le 16 Juil 2015
I extracted the data from the figures. When I plot them on the same plot they are distinct.
f4 = hgload('4.fig');
f4ax = findobj(f4,'type','axes');
f4L = findobj(f4ax, 'type', 'line');
f4x = get(f4L,'xdata');
f4y = get(f4L,'ydata');
close(f4);
f7 = hgload('7.fig');
f7ax = findobj(f7,'type','axes');
f7L = findobj(f7ax, 'type', 'line');
f7x = get(f7L,'xdata');
f7y = get(f7L,'ydata');
close(f7);
nf = figure();
nax = axes('Parent', nf);
plot(nax, f4x, f4y, 'b', f7x, f7y, 'r');
The blue part is not visible to the left because the values are essentially identical to the red values which was drawn on top of it.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Visual Exploration dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by