필터 지우기
필터 지우기

How to call the function?

조회 수: 1 (최근 30일)
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
Stephen23
Stephen23 2019년 7월 5일
편집: Stephen23 2019년 7월 5일
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.
surendra kumar Aralapura mariyappa
Thank you sir.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by