How to tabulate?

9 次查看(过去 30 天)
prem kumar
prem kumar 2022-1-29
回答: Voss 2022-1-29
hello friends i want to ask a question regarding tabulation of number of days and sdelta without the statistic toolbox.
dn=1:1:365;
x=(360/365*(dn+284));
sdelta=23.45*(sind(x)*pi/180);
Tabulate sdelta for dn = 15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345.
for normal tabulation for dn and sdelta is easy i believe but how about when the number of days is like this?i did thought about interpolation but i think it would not be that complicated and must have a simpler way to solve it ..can anyone give me a hint or guide me?.Thank you friends

采纳的回答

KSSV
KSSV 2022-1-29
You can use interp1.
dn=1:1:365;
x=(360/365*(dn+284));
sdelta=23.45*(sind(x)*pi/180);
dni = [15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345] ;
sdeltai = interp1(dn,x,dni);

更多回答(1 个)

Voss
Voss 2022-1-29
You do not need to interpolate because the dn values you want the sdelta for are all already in the vector of all dn values (i.e., 1:1:365 contains 15, 45, 75, ...); you merely need to take those indices of sdelta:
dn=1:1:365;
x=(360/365*(dn+284));
sdelta=23.45*(sind(x)*pi/180);
dni = [15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345];
sdeltai = sdelta(dni) % get elements of sdelta at indices dni
sdeltai = 1×12
-0.3712 -0.2377 -0.0422 0.1643 0.3280 0.4061 0.3783 0.2518 0.0597 -0.1480 -0.3171 -0.4035
isequal(sdeltai,interp1(dn,sdelta,dni)) % same as "interpolating"
ans = logical
1

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by