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

1 回表示 (過去 30 日間)
Yi-Kai Peng
Yi-Kai Peng 2023 年 8 月 5 日
編集済み: Yi-Kai Peng 2023 年 8 月 5 日
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 Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by