Integration using multiple formula's and a single variable.
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi Guys,
I have a question regarding these lines of code:
d = @(t) d0.*cos(2.*pi.*((t-172)./365));
c = @(d,t) sin(La).*sin(d)+cos(La).*cos(d).*cos(2*pi.*(t-0.5)-Lo);
f = @(c) c.*a0+a1.*exp(-(k./c));
Nf = integral(f,0,365);
I want to integrate the function f over t=0 to t=365. However, the function f is also dependent on formula c and d.
The way I have set it up now, f is integrated over c=0 to c=365. How can I do this?
t is the only variable, the others (La, Lo, etc) are all constants.
Thanks in advance!
댓글 수: 0
채택된 답변
Star Strider
2018년 11월 19일
You are actually integrating with respect to ‘t’. Express all your functions as function of ‘t’, and it should work.
However, this returns:
Warning: Infinite or Not-a-Number value encountered.
so you need to solve that problem.
d = @(t) d0.*cos(2.*pi.*((t-172)./365));
c = @(t) sin(La).*sin(d(t))+cos(La).*cos(d(t)).*cos(2*pi.*(t-0.5)-Lo);
f = @(t) c(t).*a0+a1.*exp(-(k./c(t)));
Nf = integral(f,0,365);
This is the correct approach.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!