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!