why won't this plot?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Steven Lord
2016-10-4
% 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')
更多回答(3 个)
Massimo Zanetti
2016-10-4
Yes, because you are plotting just on point. Better try this:
plot(xaxis,yaxis)
0 个评论
Gareth Thomas
2016-10-4
编辑:Gareth Thomas
2016-10-4
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 个评论
Gareth Thomas
2016-10-4
for i = 1:length(xaxis); hold on ;if xaxis(i) >0; plot(xaxis(i),yaxis(i),'x'); end; end;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!