How to create matrix using for loop and if statment

2 vues (au cours des 30 derniers jours)
ibrahim alzoubi
ibrahim alzoubi le 3 Août 2021
Réponse apportée : KSSV le 3 Août 2021
How Can I create for loop to fix "Matrix dimensions must agree." problem by picking a number from range 1 to 24 and simulate it.
clc
clear all
number_of_the_yearly_day = 1:1:365; %n
T=1:1:24;
declination=23.45.*sin((2.*pi.*(number_of_the_yearly_day-80))./(365));%?
latitude=31.963158; %?
Zenith_angle=latitude-declination; %??
tilt_angle=Zenith_angle;%?
altitude=1-Zenith_angle; %?
w=15.*(12-T);
Y=acosd(sin(altitude).*sin(latitude)-sin(declination)./(cos(altitude).*cos(latitude)));
X=asind(sin(declination).*sin(latitude)+cos(latitude).*cos(declination).*cos(w));
plot (X,Y)
when I simulate this it gives me "Matrix dimensions must agree.".

Réponses (1)

KSSV
KSSV le 3 Août 2021
number_of_the_yearly_day = 1:1:365; %n
T=1:1:24;
declination=23.45.*sin((2.*pi.*(number_of_the_yearly_day-80))./(365));%?
latitude=31.963158; %?
Zenith_angle=latitude-declination; %??
tilt_angle=Zenith_angle;%?
altitude=1-Zenith_angle; %?
w=15.*(12-T);
[declination,w] = meshgrid(declination,w) ;
Y=acosd(sin(altitude).*sin(latitude)-sin(declination)./(cos(altitude).*cos(latitude)));
X=asind(sin(declination).*sin(latitude)+cos(latitude).*cos(declination).*cos(w));
plot(X',Y')

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by