How to call the function?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
surendra kumar Aralapura mariyappa
le 5 Juil 2019
Commenté : surendra kumar Aralapura mariyappa
le 5 Juil 2019
Hey all,
I have two function file and one slover file. One function file for Input and another for some calculation. Here, all these files are interdependent.
For an example:
This is the user input file:
function [n,Lambda, A, B, D,H,V, Rho,cP] = Matrix_Samplemodel(Node_num, Conductivity,contact_area,Width, Diameter, Height,Volume, Density,Heat_Capacity)
% From the user input output Matrix will be built.
end
second one is conductance file
function LA = Conductance
[n,Lambda, A, B, D,H,V, Rho,cP] = Matrix_Samplemodel(Node_num, Conductivity,contact_area,Width, Diameter, Height,Volume, Density,Heat_Capacity);
% some calculation to get LA by using the output arguments of first user input file.
end
This file has to take the value from the first inuput file. But user will enter the input values in the slover file:
This is the solver file:
function SampleModel_Stat
%[n,Lambda, A, B, D,V, Rho,cP,P] = Matrix_Samplemodel(Node_num,Conductivity, contact_area,Width, Diameter,Height, Volume, Density,Heat_Capacity)
[n,Lambda, A, B, D,H,V, Rho,cP] = Matrix_Samplemodel(10, 205 , 4749.50 ,25, 55,0, 2.3746e+05 , 7760,431);
%In the solver user is giving the Input values.
LA = Conductance;
end
Now all these three are different filles.
When I run the solver it is showing erorr like below.
SampleModel_Stat
Undefined function or variable 'Node_num'.
Error in Conductance (line 3)
[n,Lambda, A, B, D,H,V, Rho,cP] = Matrix_Samplemodel(Node_num,Conductivity, contact_area,Width,
Diameter,Height, Volume, Density,Heat_Capacity);
Error in SampleModel_Stat (line 19)
LA = Conductance;
Here How can I call the output of the user input function in the second file(Conductane file) to get the LA in the solver file. But user will enter the input arguments in the Solver file, not in user input file or in conductance file.
Any suggestions and answered are most welcomed.
Thanks in advance
2 commentaires
Stephen23
le 5 Juil 2019
Modifié(e) : Stephen23
le 5 Juil 2019
As the error message clearly states, inside the function Conductance the variable Node_num is undefined (and also Conductivity, contact_area, Width, Diameter, Height, Volume, Density, and Heat_Capacity).
In MATLAB variables must be explicitly passed from one workspace to another, they do not just jump magically from another workspace where they might exist. If you want to use variables from another workspace inside Conductance, then you will need to pass them as input arguments or use nested functions.
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!