plot3 matlab的绘图保持
还有一个类似的问题,得到了答案。我的问题与这个问题相同,只是我有两个循环,而不是这里显示的一个。不过,这个解决方案似乎对我不起作用 问题是: 在这里,有一个单循环的广告解决方案似乎工作良好。以下是我的代码:plot3 matlab的绘图保持,matlab,plot,Matlab,Plot,还有一个类似的问题,得到了答案。我的问题与这个问题相同,只是我有两个循环,而不是这里显示的一个。不过,这个解决方案似乎对我不起作用 问题是: 在这里,有一个单循环的广告解决方案似乎工作良好。以下是我的代码: figure(1) for i = 1:n for j = 1:m if(condition) %some calculations to get X x = X(1,:);
figure(1)
for i = 1:n
for j = 1:m
if(condition)
%some calculations to get X
x = X(1,:);
y = X(2,:);
z = X(3,:);
plot3(x,y,z,'.');
view(3);
hold on;
end
end
hold on;
end
在这里,使用“j”对内部循环进行所有迭代之后,我得到了一个正确的绘图,但是一旦它转到外部循环,绘图就会刷新并重新开始。如何维护两个回路的plot3?我在外循环中再次使用了hold,但它似乎仍然不起作用。有人能告诉我如何维护两个循环的绘图吗。?提前感谢。我认为您的代码应该按原样工作。但是,我会做一些改变,这将有助于解决您遇到的任何问题:
等待
只需调用一次view(3)
也只需调用一次(实际上,绘制数据时根本不需要调用,只需帮助可视化即可)轴紧
对缩放轴限制进行适当的初步猜测%Set up figure to catch plots
figure(1);
hAxis = gca; %This will create an axis in the figure, and return its handle
hold on; %You can also use hold(hAxis,'on') if you are really paranoid about which axis is catching your commands
%Perform plots
for i = 1:n
for j = 1:m
if (condition)
%some calculations to get X
x = X(1,:);
y = X(2,:);
z = X(3,:);
plot3(hAxis,x,y,z,'.');
end
end
end
%Adjust view etc (experiment here after the data is plotted)
view(3)
axis tight
我认为您的代码应该按原样工作。但是,我会做一些改变,这将有助于解决您遇到的任何问题:
等待
只需调用一次view(3)
也只需调用一次(实际上,绘制数据时根本不需要调用,只需帮助可视化即可)轴紧
对缩放轴限制进行适当的初步猜测%Set up figure to catch plots
figure(1);
hAxis = gca; %This will create an axis in the figure, and return its handle
hold on; %You can also use hold(hAxis,'on') if you are really paranoid about which axis is catching your commands
%Perform plots
for i = 1:n
for j = 1:m
if (condition)
%some calculations to get X
x = X(1,:);
y = X(2,:);
z = X(3,:);
plot3(hAxis,x,y,z,'.');
end
end
end
%Adjust view etc (experiment here after the data is plotted)
view(3)
axis tight
我认为您的代码应该按原样工作。但是,我会做一些改变,这将有助于解决您遇到的任何问题:
等待
只需调用一次view(3)
也只需调用一次(实际上,绘制数据时根本不需要调用,只需帮助可视化即可)轴紧
对缩放轴限制进行适当的初步猜测%Set up figure to catch plots
figure(1);
hAxis = gca; %This will create an axis in the figure, and return its handle
hold on; %You can also use hold(hAxis,'on') if you are really paranoid about which axis is catching your commands
%Perform plots
for i = 1:n
for j = 1:m
if (condition)
%some calculations to get X
x = X(1,:);
y = X(2,:);
z = X(3,:);
plot3(hAxis,x,y,z,'.');
end
end
end
%Adjust view etc (experiment here after the data is plotted)
view(3)
axis tight
我认为您的代码应该按原样工作。但是,我会做一些改变,这将有助于解决您遇到的任何问题:
等待
只需调用一次view(3)
也只需调用一次(实际上,绘制数据时根本不需要调用,只需帮助可视化即可)轴紧
对缩放轴限制进行适当的初步猜测%Set up figure to catch plots
figure(1);
hAxis = gca; %This will create an axis in the figure, and return its handle
hold on; %You can also use hold(hAxis,'on') if you are really paranoid about which axis is catching your commands
%Perform plots
for i = 1:n
for j = 1:m
if (condition)
%some calculations to get X
x = X(1,:);
y = X(2,:);
z = X(3,:);
plot3(hAxis,x,y,z,'.');
end
end
end
%Adjust view etc (experiment here after the data is plotted)
view(3)
axis tight
我无法重现你的问题。请提供代码,包括产生问题的示例数据。我无法重现您的问题。请提供代码,包括产生问题的示例数据。我无法重现您的问题。请提供代码,包括产生问题的示例数据。我无法重现您的问题。请提供代码,包括产生问题的示例数据。