Why don't I see the graph? [No Graph visible in figure window without '+' or '.' argument]
27 次查看(过去 30 天)
显示 更早的评论
The file that is attached is an attempt on simulating a swing-by. However all I get at the end is an empty figure window.
Funnily enough I am able to see the graphs when I add a marker like '+' or '.' to my plot, so they get simulated at least. Leaving the LineSpec out of the plot or adding a Line-Style like '-' or '--' will result in an invisible graph.
It seems to run on the computer of my teacher but not on my macbook pro nor on my desktop pc. He is using a very old version of Matlab and I am currently on R2015b.
EDIT: I changed the description of my problem slightly.
0 个评论
采纳的回答
Mike Garrity
2015-12-7
When you're calling plot, you're passing in a single data point.
The linespecs '.', '+', etc. are setting the property Marker. That means that they're controlling what symbol gets drawn at each data point.
The linespecs line '-', ':', etc. are setting the property LineStyle. That means that they're controlling how lines get drawn which connect adjacent data points. Since you only have one data point, this is rather problematic in your case. If you want to draw lines connecting the points, then you really need to save the previous data point and pass two into your call to plot.
You might also want to learn about the new animatedline function, which is designed to do exactly the type of thing that you're doing here. However it was introduced in R2014b, so it won't work in that older version.
2 个评论
Mike Garrity
2015-12-10
If you mean a marker on the head of the line, the animatedline object won't do that for you. You need to add another object to do that part.
I took your code and added the following near where you initialized the waitbar.
hmars_line = animatedline('Color','red');
hmars_marker = line(nan,nan,'Marker','o','Color','red');
hsonde_line = animatedline('Color','blue');
hsonde_marker = line(nan,nan,'Marker','d','Color','blue');
axis equal
xlim([-3.3e11 2.4e11])
ylim([-2.25e11 2.25e11])
and I replaced your calls to plot with this:
hmars_line.addpoints(X_Mars(1,:),X_Mars(2,:));
hmars_marker.XData = X_Mars(1,:);
hmars_marker.YData = X_Mars(2,:);
hsonde_line.addpoints(X_Sonde(1,:),X_Sonde(2,:));
hsonde_marker.XData = X_Sonde(1,:);
hsonde_marker.YData = X_Sonde(2,:);
The result looks like this:
更多回答(1 个)
Walter Roberson
2015-11-29
Try moving the "hold on" to after the first plot3()
In R2014b and later, "hold on" becomes the same as "hold all", but that can have the effect of freezing the axes limits, so if you "hold on" before you have plotted anything then you might not be able to see the output.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!