Effacer les filtres
Effacer les filtres

Integration using multiple formula's and a single variable.

1 vue (au cours des 30 derniers jours)
Tim Stark
Tim Stark le 19 Nov 2018
Commenté : Star Strider le 19 Nov 2018
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!

Réponse acceptée

Star Strider
Star Strider le 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.
  2 commentaires
Tim Stark
Tim Stark le 19 Nov 2018
Thanks Star Strider!
Star Strider
Star Strider le 19 Nov 2018
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by