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

2 次查看(过去 30 天)
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.

采纳的回答

Yi-Kai Peng
Yi-Kai Peng 2023-8-5
编辑:Yi-Kai Peng 2023-8-5
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 个评论
Torsten
Torsten 2023-8-5
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 2023-8-5
编辑:Yi-Kai Peng 2023-8-5
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).

请先登录,再进行评论。

更多回答(1 个)

Torsten
Torsten 2023-8-5
移动:Torsten 2023-8-5
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.

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by