How to call the function?

1 visualizzazione (ultimi 30 giorni)
surendra kumar Aralapura mariyappa
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 Commenti
Stephen23
Stephen23 il 5 Lug 2019
Modificato: Stephen23 il 5 Lug 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.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Debugging and Analysis in Help Center e File Exchange

Prodotti


Release

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by