why won't this plot?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Don
el 4 de Oct. de 2016
Comentada: Don
el 4 de Oct. de 2016
for i = 1:length(xaxis); if xaxis(i) >0; plot(xaxis(i),yaxis(i)); end
end;
xaxis and yaxis have numbers. I always get a blank plot space
0 comentarios
Respuesta aceptada
Steven Lord
el 4 de Oct. de 2016
% Sample data
xaxis = -2*pi:0.1:2*pi;
yaxis = sin(xaxis);
% Determine the points with positive x coordinates and plot them
positiveXAxisMask = xaxis > 0;
plot(xaxis(positiveXAxisMask ), yaxis(positiveXAxisMask ), 'x')
% Let's plot the negative x coordinates as well for illustration
hold on
plot(xaxis(~positiveXAxisMask ), yaxis(~positiveXAxisMask ), 'o')
Más respuestas (3)
Massimo Zanetti
el 4 de Oct. de 2016
Yes, because you are plotting just on point. Better try this:
plot(xaxis,yaxis)
0 comentarios
Gareth Thomas
el 4 de Oct. de 2016
Editada: Gareth Thomas
el 4 de Oct. de 2016
You need to add the hold on command. Try this:
for i = 1:length(xaxis); hold on;if xaxis(i) >0; plot(xaxis(i),yaxis(i),'x'); end; end;
Notice the 'x' which helps you see it.
0 comentarios
Gareth Thomas
el 4 de Oct. de 2016
for i = 1:length(xaxis); hold on ;if xaxis(i) >0; plot(xaxis(i),yaxis(i),'x'); end; end;
0 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!