hey gays ive written a code @ it dosent have an error but it doesnt plot what i want what can i do with this ?
clear
t=16;
d=23;
M=5;
N1=floor(((275*(1/M))-30+d)-2);
s1=23.45*sind((360/365)*(284+(N1+2)));
l=35.44;
B=(N1-81)*360/364;
h=0.25*(t-12)*60;
z(1)=0;
while z<pi
z=0.1+z;
x=sin(l)*sin(s1)*cos(B)-cos(l)*sin(s1)*sin(B)*cos(z)+cos(l)*cos(s1)*cos(h)*cos(B)+sin(l)*cos(s1)*cos(h)*sin(B)*cos(z)+cos(s1)*sin(h)*sin(B)*sin(z)
theta=acos(x)
plot(theta,z)
end

댓글 수: 6

Bob Thompson
Bob Thompson 2019년 4월 8일
It looks like theta and x are both single values, so your results will just be a series of points. Matlab doesn't usually show points of lines in a very obvious manner. Are you sure it isn't plotting, and the problem is just not the visibility. You can test this by changing the format of the points of the plot.
Alex Mcaulley
Alex Mcaulley 2019년 4월 8일
What do you want to plot? In this code you are plotting one point (the last value of theta, z)
Bob Thompson
Bob Thompson 2019년 4월 8일
Also, as Alex mentioned, you are currently only plotting the last point of theta and x. Put 'hold on' before the while loop if you want to plot all points.
fatemeh jan
fatemeh jan 2019년 4월 8일
i used hold on and no change
fatemeh jan
fatemeh jan 2019년 4월 8일
i want to plot(theta,z) with 0< z<pi and theta they result
fatemeh jan
fatemeh jan 2019년 4월 8일
i used plot(theta,z,'*') and it worked :D

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

 채택된 답변

Alex Mcaulley
Alex Mcaulley 2019년 4월 8일

0 개 추천

Then, you simply need this:
t=16;
d=23;
M=5;
N1=floor(((275*(1/M))-30+d)-2);
s1=23.45*sind((360/365)*(284+(N1+2)));
l=35.44;
B=(N1-81)*360/364;
h=0.25*(t-12)*60;
z = 0:0.1:pi;
theta = acos(sin(l)*sin(s1)*cos(B)-cos(l)*sin(s1)*sin(B)*cos(z)+cos(l)*cos(s1)*cos(h)*cos(B)+sin(l)*cos(s1)*cos(h)*sin(B)*cos(z)+cos(s1)*sin(h)*sin(B)*sin(z));
plot(theta,z)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2019년 4월 8일

댓글:

2019년 4월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by