Fixed axes during the iterations to plot 3D lines between two points

Hello everyone,
I tried to write the code to plot a moving line in 3D by using the following code:
r = 3;
theta = linspace(0,2*pi,20);
lt = length(theta);
phi = pi/4;
for i = 1:lt
plot3([0 3*cos(phi)*cos(theta(i))], [0 3*cos(phi)*sin(theta(i))], [0 3*cos(phi)],'-b.','MarkerSize',20)
grid on
xlim = ([-3 3])
ylim = ([-3 3])
zlim = ([-0.5 3.5])
pause(0.3)
end
I would like to visualize a fixed reference frame (see xlim, ylim, zlim), for example: x axis also ways from left to the right, z axis always from bottom to top. My code gives me a reference frame whose axes change during the code execution.
I tried also by using the statement view (e.g. view(-37.500,30) which is the view after the last iteration), but the situation is the same.
EDIT: screenshot during the execution (I added hold on statement).
Thank you so much for your willingness.

 채택된 답변

xlim([-3 3])
ylim([-3 3])
zlim([-0.5 3.5])

댓글 수: 3

Gennaro Arguzzi
Gennaro Arguzzi 2018년 11월 10일
편집: Gennaro Arguzzi 2018년 11월 10일
Hello @WalterRoberson, my code does not work and it contains the above three statements. It's quite strange. As you can see in the above figure, the negative part of the axes does not appear.
Bruno Luong
Bruno Luong 2018년 11월 10일
편집: Bruno Luong 2018년 11월 10일
your code contain
xlim = ([-3 3]);
The equal sign is wrong, Walter deleted it. You have to do
>> clear all
Before rerun the fixed code
Thank you so much @Walter Roberson and @Bruno Luong.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

질문:

2018년 11월 10일

편집:

2018년 11월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by