how to find x if i only know y?

2 views (last 30 days)
Iris Kiebert
Iris Kiebert on 15 Dec 2019
Answered: Iris Kiebert on 15 Dec 2019
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 i_days=n
sino=-23.45*(pi/180)*cos(((2*pi)/365)*(10+n)); %the declination angle should be a function of day number,so o the declination angle is the inverse sinus of sino (the sinus of de declination angle
o=asind(sino); %this is the inclination angle
end
how do i calculate the n for o=0. in know that for o=0, sino=0,5*pi or 1,.5*pi
  1 Comment
Walter Roberson
Walter Roberson on 15 Dec 2019
https://www.mathworks.com/matlabcentral/answers/496717-my-code-doesnt-show-a-graph-even-if-i-use-the-plot-command has some code fixes for you

Sign in to comment.

Accepted Answer

Jesus Sanchez
Jesus Sanchez on 15 Dec 2019
As you are working with degrees, I consider that you want to have natural numbers as a result, not something like 5.0358 degrees, with decimals. Therefore, I included "round" in the code. Then I just apply an "if" commando and store the days when o is 0:
close all
clear
clc
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;
result = []; % To store the days when o is 0
for i_days=1:length(n)
sino=-23.45*(pi/180)*cos(((2*pi)/365)*(10+n(i_days))); %the declination angle should be a function of day number,so o the declination angle is the inverse sinus of sino (the sinus of de declination angle
o=asind(sino); %this is the inclination angle
o = round(o); % This round to a natural number. Change precission or comment if you dont want it.
if o == 0
result(end+1) = n(i_days); % Store day
end
end
fprintf('Days where o is equal to 0 deg:\n ');
fprintf('%g ', result);
  2 Comments
Jesus Sanchez
Jesus Sanchez on 15 Dec 2019
You just need to change the line:
if o == 0
Instead of 0, you can write any number. Also, take care as I rounded the results of o, you should either use natural numbers in the if condition or comment o = round(o). If you want several values to be checked at the same time, that is also possible using vectors, for loops or even a built-in function called find.

Sign in to comment.

More Answers (1)

Iris Kiebert
Iris Kiebert on 15 Dec 2019
thanks!!

Tags

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!