Using output of a function into the integral2 Function - Unrecognized function or variable
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I'm currently facing an issue with using an output of a function into an integral.
I have attached my code for reference:
P_RAD.m
Unfortunately, for this case, I have to use a function in my code because I need it to plot certain parameters. I understand what the error is saying and why it is saying it. I'm trying to see if there is a workaround for this.
This is the integration I am trying to do: See screenshot attached: P_RAD_Integration.png
The error that I'm facing is shown below.
% Unrecognized function or variable 'U_Rad'.
Error in Patterns (line 200)
P_rad = U_Rad.*sin(theta);
0 件のコメント
採用された回答
Walter Roberson
2024 年 7 月 11 日
U_Rad is defined only as the nominal output variable of function Cuts.
You call
E_Plane(n) = Cuts(loop_theta, phi_E);
% Specifying the H_Plane cut as an array with theta values and phi_H
H_Plane(n) = Cuts(loop_theta, phi_H);
so the values assigned internally to U_Rad inside the function are transfered to output variables E_Plane and H_Plane
P_rad = U_Rad.*sin(theta);
P_rad_function = matlabFunction(P_rad);
Besides U_Rad being undefined here: you do not have any symbolic variables, so you cannot construct a matlabFunction
What you need is
syms theta phi
P_rad = Cuts(theta,phi).*sin(theta);
P_rad_function = matlabFunction(P_rad, 'Vars', [theta, phi]);
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!