how to find x if i only know y?

조회 수: 4 (최근 30일)
Iris Kiebert
Iris Kiebert 2019년 12월 15일
답변: Iris Kiebert 2019년 12월 15일
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
Walter Roberson
Walter Roberson 2019년 12월 15일
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

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

채택된 답변

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

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

추가 답변 (1개)

Iris Kiebert
Iris Kiebert 2019년 12월 15일
thanks!!

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by