Clear Filters
Clear Filters

Integration using multiple formula's and a single variable.

1 view (last 30 days)
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!

Accepted Answer

Star Strider
Star Strider on 19 Nov 2018
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.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!