필터 지우기
필터 지우기

How can I draw a trajectory like this?

조회 수: 2 (최근 30일)
Zeinab Ahmadi93
Zeinab Ahmadi93 2017년 6월 28일
댓글: Zeinab Ahmadi93 2017년 7월 2일
Hello everybody Would you help me draw a trajectory like this using sin and cos functions but not with these stars, I want it with solid and continuous line.I have found this piece of code but i couldn't get a clue. Thanks in advance.
c1=30;
c2=30;
for j=1:3
for i=1:1:8 %%%2nd for loop for no. of S in the column
if(mod(i,2)~=0) %%%for C structure and opposite C structure
th = linspace( pi/2, -pi/2, 10);
for k=1:1:length(th)
anchormove(1,idx) = r *-cos(th(k)) + c1;
anchormove(2,idx) = r *-sin(th(k)) + c2;
idx=idx+1;
end
else
th = linspace( -pi/2, pi/2, 10);
for k=1:1:length(th)
anchormove(2,idx) = r * sin(th(k)) + c2;
anchormove(1,idx) = r * cos(th(k)) + c1;
idx=idx+1;
end
end
c2=c2+60;
end
lastmove=anchormove(2,idx-1);
for i=anchormove(1,idx-1):10: anchormove(1,idx-1)+(r+60)
anchormove(1,idx) = i;
anchormove(2,idx) = lastmove;
idx=idx+1;
end
c2=450;
c1=c1+90;
for i=1:1:8 %%%2nd for loop for no. of S in the column
if(mod(i,2)~=0) %%%for C structure and opposite C structure
th = linspace( pi/2, -pi/2, 10);
for k=1:1:length(th)
anchormove(1,idx) = r *cos(th(k)) + c1;
anchormove(2,idx) = r *sin(th(k)) + c2;
idx=idx+1;
Ax=anchormove(1,i);
Ay=anchormove(2,i);
plot(Ax,Ay,'r*')

채택된 답변

Image Analyst
Image Analyst 2017년 6월 28일
Use 'r-' instead of 'r*'.
  댓글 수: 3
Image Analyst
Image Analyst 2017년 6월 28일
편집: Image Analyst 2017년 6월 28일
Attach your code here. I'm not going out to any third party site when you can attach it here with the paper clip icon. Your code as pasted above doesn't work. There are at least 3 "end" statement missing. I don't know where to put them because the formatting and indenting is all messed up. You can type control-a then control-i to fix indenting before pasting here. Please post code that runs.
Zeinab Ahmadi93
Zeinab Ahmadi93 2017년 7월 2일
Ok Thanks dear Image Analyst for your guidance...I corrected my code and it runs. But I have another question, Would you please help me. I posted it here
https://www.mathworks.com/matlabcentral/answers/347079-how-can-i-set-an-equal-distance-of-5-units-between-the-red-star-points

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 WSNs에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by