Filter löschen
Filter löschen

How can I draw a trajectory like this?

2 Ansichten (letzte 30 Tage)
Zeinab Ahmadi93
Zeinab Ahmadi93 am 28 Jun. 2017
Kommentiert: Zeinab Ahmadi93 am 2 Jul. 2017
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*')

Akzeptierte Antwort

Image Analyst
Image Analyst am 28 Jun. 2017
Use 'r-' instead of 'r*'.
  3 Kommentare
Image Analyst
Image Analyst am 28 Jun. 2017
Bearbeitet: Image Analyst am 28 Jun. 2017
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 am 2 Jul. 2017
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu WSNs finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by