function command hellp

조회 수: 5 (최근 30일)
Nasir Qazi
Nasir Qazi 2012년 2월 14일
편집: Cedric 2013년 10월 12일
I have a function file have code like this
--------------------------------------------
function GH = Gibbs(R,T,Z,A,B)
% Calculate the Enthalpy, Enropy, Gibbs free energy
GH = R*T*((Z-1)- log(Z-B)- A/B*log(Z+B/Z));
end
------------------------------------------
I have values of R, T, Z, A, B in another m-file , how I compute this by calling the other file for the values of R,T,Z,A,B

답변 (2개)

Honglei Chen
Honglei Chen 2012년 2월 14일
Let's say the other file is foo.m, then you can modify the signature of foo to return those values, e.g.
function [...,R,T,Z,A,B] = foo(...)
Then you can call them in sequence like this:
[...,R,T,Z,A,B] = foo(...);
GH = Gibbs(R,T,Z,A,B);
  댓글 수: 5
Nasir Qazi
Nasir Qazi 2012년 2월 14일
r u there/?
Honglei Chen
Honglei Chen 2012년 2월 14일
I'm starting a new answer

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


Honglei Chen
Honglei Chen 2012년 2월 14일
Then I will rewrite the other file into a function, using signatures like
function [T,Z,A,B] = foo(R)
Once you do that, you can call them in order
[T,Z,A,B] = foo(R)
GH = Gibbs(R,T,Z,A,B)
  댓글 수: 13
Honglei Chen
Honglei Chen 2012년 2월 14일
Then you can call it within the other file
function GH = Gibbs
% Calculate the Enthalpy, Enropy, Gibbs free energy
[R,T,A,Z,B] = foo;
GH = R*T*((Z-1)- log(Z-B)- A/B*log(Z+B/Z));
end
Nasir Qazi
Nasir Qazi 2012년 2월 14일
thats it thats wht i am looking for. thx so much

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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by