my code doesnt show a graph even if i use the plot command
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
close all
clear all
h=[1:24];%hours in day
m=[1:14400];%minutes in day
n_param=5;
n=[1:365];%days in year
az=0.0001; % degrees %a=0,001 , because a is near zero during sunrise and sunset.
ndec=355; %21 december is de 335e dag van het jaar
njul=202; %21 juli is de 202e dag van het jaar
p=52.3667; %altitude amsterdam
heigthblock=25; %heigth of the block in mETER
sino=zeros(1,365);
max_loops = 100;
for n_days=n %azimuth angle
sinoaz=-23.45*(pi/180)*cos(((2*pi)/365)*(10+n));
oaz=asind(sinoaz);
%wm=(m+7200)*pi/7200;
%sin(a)=cos(o)*cos(wh)*cos(p)+sino*sin(p)
%sin(a)-sino*sin(p)=cos(o)*cos(wh)*cos(p)
%cos(wh)=(sin(a)-sino*sin(p))/((cos(o)*cos(p)))
coswm=(sind(az)-(sinoaz*sind(p)))./((cosd(oaz).*cosd(p)));
wmaz=acos(coswm);
sinaaz=sind(az);
sinAz=(sin(wmaz).*cosd(oaz))./sinaaz;
A=asind(sinAz);
end
figure
plot(n,A)
0 Kommentare
Antworten (2)
Walter Roberson
am 15 Dez. 2019
sinoaz=-23.45*(pi/180)*cos(((2*pi)/365)*(10+n));
Should use n_days instead of n
A=asind(sinAz);
Should be
A(n_days)=asind(sinAz);
I have not executed your code but I also suspect that you might be generating complex-valued A values.
0 Kommentare
Bhaskar R
am 15 Dez. 2019
Here variable A is complex number. So MATLAB automatically recognise as complex value and plot as real values of the complex number
You can plot real and imaginary values together or individually or with repect to n
In your code there is no effect of for loop,
your code is
close all
clear all
h=[1:24];%hours in day
m=[1:14400];%minutes in day
n_param=5;
n=[1:365];%days in year
az=0.0001; % degrees %a=0,001 , because a is near zero during sunrise and sunset.
ndec=355; %21 december is de 335e dag van het jaar
njul=202; %21 juli is de 202e dag van het jaar
p=52.3667; %altitude amsterdam
heigthblock=25; %heigth of the block in mETER
sino=zeros(1,365);
max_loops = 100;
% for n_days=n %azimuth angle
sinoaz=-23.45*(pi/180)*cos(((2*pi)/365)*(10+n));
oaz=asind(sinoaz);
%wm=(m+7200)*pi/7200;
%sin(a)=cos(o)*cos(wh)*cos(p)+sino*sin(p)
%sin(a)-sino*sin(p)=cos(o)*cos(wh)*cos(p)
%cos(wh)=(sin(a)-sino*sin(p))/((cos(o)*cos(p)))
coswm=(sind(az)-(sinoaz*sind(p)))./((cosd(oaz).*cosd(p)));
wmaz=acos(coswm);
sinaaz=sind(az);
sinAz=(sin(wmaz).*cosd(oaz))./sinaaz;
A=asind(sinAz);
% end
% real Vs imaginary of A
figure,plot(real(A), imag(A)),title('real Vs imaginary of A ') ;
% n_days(n) Vs real of A
figure, plot(n, real(A)), title('n\_days(n) Vs real of A') ;
% n_days(n) Vs imaginary of A
figure, plot(n, imag(A)), title('n\_days(n) Vs imaginary of A');
1 Kommentar
Walter Roberson
am 16 Dez. 2019
Bearbeitet: Walter Roberson
am 16 Dez. 2019
It does get confusing to be using a mix of degrees and radians in the calculations. It would be more consistent to use acosd for wmaz and sind(wmaz)
But would probably be even easier on people if deg2rad() was used on the parts that had to be in degrees (definition of az, and the -23.45 constant) and use radians everywhere else.
In particular look more carefully at the line
sinoaz=-23.45*(pi/180)*cos(((2*pi)/365)*(10+n));
The -23.45*pi/180 is converting -23.45 degrees to radians, and the cos() part is producing radians, so sinoaz must be in radians, but on the next line you asind() it.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!