フィルターのクリア

Function requires more inputs

1 回表示 (過去 30 日間)
Matthew Tom
Matthew Tom 2018 年 5 月 26 日
回答済み: Walter Roberson 2018 年 5 月 26 日
Hi! I am trying to work the following code, but it keeps saying that I need more inputs:
function r = rxnrate(F)
global k Keq
Fa=F(1);
Fb=F(2);
Fc=F(3);
Fd=F(4);
f=33.3;
P=1;
Pa=(Fa/f)*P;
Pb=(Fb/f)*P;
Pc=(Fc/f)*P;
Pd=(Fd/f)*P;
r(1)=k*((Pa*Pb)-(Pc*Pd/Keq));
r(2)=k*((Pa*Pb)-(Pc*Pd/Keq));
r(3)=k*((Pa*Pb)-(Pc*Pd/Keq));
r(4)=k*((Pa*Pb)-(Pc*Pd/Keq));
r=r';
end

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 5 月 26 日
To run that code, you need to have first executed some code that used
global k Keq
and then assigned values to k and Keq.
That having been done once, you need to invoke the routine passing in data, such as
ftest = randn(1,4);
result = rxnrate(ftest);
It is not possible to invoke the code by simply typing the name of the function, or by simply pressing the green Run button while you are in the editor on this function. Even if you have defined F in your current workspace, MATLAB will not look for an F in the hierarchy if you try to invoke rxnrate without passing in anything.

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by