Integrating a constant in MATLAB
Afficher commentaires plus anciens
Hello,
I have a question about integrating a constant in MATLAB R=5 mess=@(T)R*T; integral(mess,20, 30) I get an answer. Or I do R=5 mess=@(T)R+T; integral(mess,20, 30), I also get the appropriate answer. But when I do R=5 mess=@(T)R; integral(mess,20, 30) The response I get is:
Error using integralCalc/finalInputChecks (line 515) Output of the function must be the same size as the input. If FUN is an array-valued integrand, set the 'ArrayValued' option to true.
Error in integralCalc/iterateScalarValued (line 315) finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 133) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 76) [q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 89) Q = integralCalc(fun,a,b,opstruct);
Error in Untitled8 (line 6) integral(mess,20, 30)
It seems that it has something to do with the fact that I'm integrating a constant that is not affected by T? Is there a way to calculate the integral without having write out the integral as R(T2-T1)?
Réponse acceptée
Plus de réponses (1)
Andrei Bobrov
le 17 Nov 2013
R=5
mess=@(T)R;
integral(mess,20, 30, 'ArrayValued',true)
Catégories
En savoir plus sur Calculus dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!