why i get this error when using integral?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75) [q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct);
T = 5;
t = linspace(0,5*T,5*500+1); % 5 cycles
t = t(1:end-1);
n = (1:3).';
a0 = (1/T) * integral(@(t) exp((10 - t) / 2), 0, 5);
an = (2/T) * integral(@(t) exp((10 - t) / 2).*cos(2*pi*f0*n*t), 0, 5);
the error occurs when computing an
even when i try the time vector without multiplying by 5. the same problem occurs
0 commentaires
Réponse acceptée
Torsten
le 27 Mar 2018
The solution is given in the error message:
an = (2/T) * integral(@(t) exp((10 - t) / 2).*cos(2*pi*f0*n*t), 0, T, 'ArrayValued',true);
By the way: You don't need to specify the t-vector ; "integral" will use ist own spatial gridding.
Best wishes
Torsten.
1 commentaire
Kedar Bahulkar
le 20 Mar 2021
Modifié(e) : Kedar Bahulkar
le 20 Mar 2021
Hello, Thankyou @Torsten. I had the same error and it got solved by your answer. I want to know, whether it is necessary to add
...'ArrayValued',true)
when performing numerical integration always?
Thank you
Kedar
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Bartlett dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!