Using output of a function into the integral2 Function - Unrecognized function or variable
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Walter Roberson
il 11 Lug 2024
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]);
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!