Not obtaining the right shape with matlab plot

조회 수: 2 (최근 30일)
Vedant Parwal
Vedant Parwal 2019년 6월 24일
댓글: Vedant Parwal 2019년 6월 25일
Hey everyone!
I have been tring to generate a profile on matlab. I have written the parametric equation and plotted it.
I tried my code for a known set of values and obtained a plot which doesnt look exactly like it should, I wonder what's wrong?
My code-
phi=linspace(0,2*pi,100000);
N_ask='N';
dt_ask='dt';
R_ask='R';
E_ask='E';
Rr_ask='Rr';
N=input(N_ask)
dt=input(dt_ask)
R=input(R_ask)
E=input(E_ask)
Rr=input(Rr_ask)
r3=E*N;
si=atan(sin((N+1).*phi)/(R./r3-cos((N+1).*phi)));
x2c=R.*cos(phi)+(Rr+dt).*cos(phi+si)+E.*cos(N.*phi);
y2c=R.*sin(phi)+(Rr+dt).*sin(phi+si)-E.*sin(N*phi);
plot(x2c,y2c)
The output that I got for N=8, dt=0, R=32, E=3.5, Rr=4-
figure.PNG
But what it really should look like -
real look.PNG

채택된 답변

G A
G A 2019년 6월 24일
Add a dot ./ in the line:
si=atan(sin((N+1).*phi)./(R./r3-cos((N+1).*phi)));
  댓글 수: 1
Vedant Parwal
Vedant Parwal 2019년 6월 25일
Oops!
Stupid mistake, I should have gone through it myself.
Thanks a ton for going through the entire thing!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by