how to find x if i only know y?

1 visualizzazione (ultimi 30 giorni)
Iris Kiebert
Iris Kiebert il 15 Dic 2019
Risposto: Iris Kiebert il 15 Dic 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 Commento
Walter Roberson
Walter Roberson il 15 Dic 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

Accedi per commentare.

Risposta accettata

Jesus Sanchez
Jesus Sanchez il 15 Dic 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 Commenti
Iris Kiebert
Iris Kiebert il 15 Dic 2019
this works pretty well, does it also work when i want to know on which days o= -24.1596?
Jesus Sanchez
Jesus Sanchez il 15 Dic 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.

Accedi per commentare.

Più risposte (1)

Iris Kiebert
Iris Kiebert il 15 Dic 2019
thanks!!

Categorie

Scopri di più su Earth and Planetary Science in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by