Why is my plot not working with the for loop?
조회 수: 2 (최근 30일)
이전 댓글 표시
I am trying to plot multiple helices in one plot but for some reason I am only getting one helix with my code below...
clc;
close all;
n = input('number of turns ');
r = input('radius ');
h = input('length ');
w = input ('number of wires ');
e = (2*pi)/(w/2); %theta (where the wire is starting)
for i=1:1:w/2
t = (i-1)*e:pi/100:(n*2*pi)+(e*(i-1)); %t value for CCW helices
x = r*sin(t);
y = r*cos(t);
z = (h/(n*2*pi))*t;
end
plot3(x,y,z, 'blue') %plot CCW helices
답변 (1개)
KALYAN ACHARJYA
2018년 6월 13일
편집: KALYAN ACHARJYA
2018년 6월 13일
clc; close all;
n=input('number of turns ');
r=input('radius ');
h=input('length ');
w=input('number of wires ');
e=(2*pi)/(w/2); %theta (where the wire is starting)
for i=1:1:w/2
t =(i-1)*e:pi/100:(n*2*pi)+(e*(i-1)); %t value for CCW helices
x=r*sin(t);
y=r*cos(t);
z=(h/(n*2*pi))*t;
plot3(x,y,z) %plot CCW helices
hold on;
end
hold off;

댓글 수: 8
KALYAN ACHARJYA
2018년 6월 13일
e=40;
plot3(x,y,z,'linewidth',2) %plot CCW helices
hold on
Enter
number of turns 3
radius 4
length 20
number of wires 10
Result

참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!