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
prem kumar
prem kumar 2022년 1월 29일
owh ok noted thank you friend.

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

추가 답변 (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