Integration using multiple formula's and a single variable.

5 Ansichten (letzte 30 Tage)
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!

Akzeptierte Antwort

Star Strider
Star Strider am 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.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by