Hi, I have the following code in Matlab and the red helix is coming out choppy. I am new to this and trying to make it look pretty! I wanted to have the red and blue plots display together, and then place a point on one of them; placing a green point on an intersection would be cool. (I can figure that out math wise, but I don't know how to make the green point "pop out") Thanks for any help!
t = 0:pi/20:10*pi;
xt = sin(t);
yt = cos(t);
plot3(xt,yt,t,'-o','Color','b','MarkerSize',10)
hold on
t5 = 5;
xt5 = sin(5);
yt5 = cos(5);
plot3(t5,xt5,yt5,'MarkerSize',200,'Color','g')
xt = sin(5*t);
yt = cos(5*t);
plot3(xt,yt,t,'-','Color','r','MarkerSize',10)
hold off
axis equal
xlim([-1, 1]);
ylim([-1, 1]);
zlim([0, 5]);

 채택된 답변

Image Analyst
Image Analyst 2022년 6월 30일

0 개 추천

You don't have many points in t. Try using linspace and specify a larger number.
t = linspace(0, 10*pi, 2000);
xt = sin(t);
yt = cos(t);
plot3(xt,yt,t,'-o','Color','b','MarkerSize',10)
hold on
t5 = 5;
xt5 = sin(5);
yt5 = cos(5);
plot3(t5,xt5,yt5,'MarkerSize',200,'Color','g')
xt = sin(5*t);
yt = cos(5*t);
plot3(xt,yt,t,'-','Color','r','MarkerSize',10)
hold off
axis equal
xlim([-1, 1]);
ylim([-1, 1]);
zlim([0, 5]);

댓글 수: 2

Joshua Leiter
Joshua Leiter 2022년 6월 30일
Awesome! Thanks this solved my problem! I appreciate the help!
Image Analyst
Image Analyst 2022년 6월 30일
If youi want the green spot to be on top, you can plot it last, after everything else has plotted. Thanks for Accepting. 🙂

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

추가 답변 (1개)

William Rose
William Rose 2022년 6월 30일
편집: William Rose 2022년 6월 30일

0 개 추천

The plot order on the line to plot the green marker was wrong. Fixed. Fill in the marker with MarkerFaceColor, and black outline, to make it pop out. Extend z (time) axis. Add grid to help viewer appreciate the 3D perspective. See attached.
t = 0:pi/20:10*pi;
xt = sin(t);
yt = cos(t);
plot3(xt,yt,t,'-o','Color','b','MarkerSize',10)
hold on
t5 = 5;
xt5 = sin(5);
yt5 = cos(5);
plot3(xt5,yt5,t5,'ko','MarkerSize',15,'MarkerFaceColor','g')
xt = sin(5*t);
yt = cos(5*t);
plot3(xt,yt,t,'-','Color','r','MarkerSize',10)
hold off, grid on
axis equal
xlim([-1, 1]);
ylim([-1, 1]);
zlim([0, 6]);
Good luck!

댓글 수: 2

Joshua Leiter
Joshua Leiter 2022년 6월 30일
Oooo! This is great! Thanks this also really helps! I appreciate all the syntaxical things I missed! No wonder it wasn't working.... The MarkerFaceColor comment is really helpful too
William Rose
William Rose 2022년 6월 30일
@Joshua Leiter, you're welcome.

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

카테고리

제품

릴리스

R2022a

질문:

2022년 6월 29일

댓글:

2022년 6월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by