How to tabulate?

9 views (last 30 days)
prem kumar
prem kumar on 29 Jan 2022
Answered: Voss on 29 Jan 2022
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

Accepted Answer

KSSV
KSSV on 29 Jan 2022
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 Comment
prem kumar
prem kumar on 29 Jan 2022
owh ok noted thank you friend.

Sign in to comment.

More Answers (1)

Voss
Voss on 29 Jan 2022
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

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!