Borrar filtros
Borrar filtros

why i get this error when using integral?

14 visualizaciones (últimos 30 días)
ocsse
ocsse el 27 de Mzo. de 2018
Editada: Kedar Bahulkar el 20 de Mzo. de 2021
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

Respuesta aceptada

Torsten
Torsten el 27 de Mzo. de 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 comentario
Kedar Bahulkar
Kedar Bahulkar el 20 de Mzo. de 2021
Editada: Kedar Bahulkar el 20 de Mzo. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by