Error of "Integrand output size does not match the input size."

1 visualización (últimos 30 días)
Hello,
I am trying to make a double integral over two equtions, respectively. The equations are as following:
v_induced = u .* (1 + a_fit);
v_slipstream = u .* (1 + (2 .* a_fit));
bl_induced = @(u,z) Oper.rho .* (v_induced ./ Oper.Vinf) .* 0.5 .* (Oper.Vinf^2 - (v_induced .^2));
ke_out_induced = @(u,z) Oper.rho .* (v_slipstream ./ Oper.Vinf) .* 0.5 .* ((v_slipstream - Oper.Vinf).^2);
% Perform double integral
q1_induced = integral2(bl_induced, 0, delta99, 0, 2*pi);
q2_induced = integral2(ke_out_induced, 0, delta99, 0, 2*pi);
D_induced = q1_induced + q2_induced;
However, when I am trying to make a double integral, MATLAB throws an error
Integrand output size does not match the input size.
u and a_fit is 1x30 double, and Oper.Vinf and Oper.rho are 1x1 double. I have checked the dimension but I don't see any problem.
Does anyone know what is wrong in my code?
I appriciate any help. Thanks.

Respuesta aceptada

Yi-Kai Peng
Yi-Kai Peng el 5 de Ag. de 2023
Editada: Yi-Kai Peng el 5 de Ag. de 2023
Turns out I didn't assign the correct input to the function...
It should be bl_induced = @(v_induced ,z) instead of bl_induced = @(u,z).
Thanks for all the help!
  2 comentarios
Torsten
Torsten el 5 de Ag. de 2023
What was z ?
And notice that your settings before
v_induced = u .* (1 + a_fit);
v_slipstream = u .* (1 + (2 .* a_fit));
are not used in the calculation of the two double integrals.
Yi-Kai Peng
Yi-Kai Peng el 5 de Ag. de 2023
Editada: Yi-Kai Peng el 5 de Ag. de 2023
Hello Torsten,
yes I noticed that those two variables are not used in the calculation. Do you know any way to solve this problem? Also, z is the second integral that I want to integrate in azimuthal direction (0 to 2*pi).

Iniciar sesión para comentar.

Más respuestas (1)

Torsten
Torsten el 5 de Ag. de 2023
Movida: Torsten el 5 de Ag. de 2023
As written,
Oper.rho .* (v_induced ./ Oper.Vinf) .* 0.5 .* (Oper.Vinf^2 - (v_induced .^2));
and
Oper.rho .* (v_slipstream ./ Oper.Vinf) .* 0.5 .* ((v_slipstream - Oper.Vinf).^2);
are constant arrays of size 1x30 that do not depend on the formal integration parameters u and z.
So in principle, you integrate a constant vector over the rectangle [0, delta99] x [0, 2*pi].
I guess this is not what you want.
The error message stems from the fact that MATLAB expects a vector of the size of u and z as output from your function handle. But you always return the constant array of size 1x30.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by