Azzera filtri
Azzera filtri

Function requires more inputs

1 visualizzazione (ultimi 30 giorni)
Matthew Tom
Matthew Tom il 26 Mag 2018
Risposto: Walter Roberson il 26 Mag 2018
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

Risposte (1)

Walter Roberson
Walter Roberson il 26 Mag 2018
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.

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by