フィルターのクリア

Displaying string with variables

1 回表示 (過去 30 日間)
Rick
Rick 2015 年 11 月 9 日
コメント済み: Walter Roberson 2015 年 11 月 9 日
Hello,
I'm trying to make a function that tell me the coefficients x,y, and z for a given n,a,b,c,d CnHaObNcSd + xH2O ---> yCH4 + zCO2 + cNH3 + dH2S
And return at output with a sentence
function ChemicalFormula = foodwastes(n,a,b,c,d)
x = n - a/4 - b/2 + 3/4*c + d/2;
y = n/2 + a/8 - b/4 - 3/8*c - d/4;
z = n/2 - a/8 + b/4 + 3/8*c + d/4;
display([' C ',num2str(n), 'H' ,num2str(a), ' O ' ,num2str(b), ' N ' ,num2str(c), ' S ' ,num2str(d),
' + ' ,num2str(x), ' H_{2}O \rightarrow ',num2str(y), ' CH_{4} + ' ,num2str(z), ' CO_{2} + ' ,num2str(c),
' NH_{3} + ' ,num2str(d), ' H_{2}S '])
MW = 16*n + 1*a + 16*b + 14*c + 32*d;
diplay(['Food Waste Molecular weight is ' num2str(MW)]);
However, I keep getting this error
Undefined function 'foodwastes' for input
arguments of type 'double'.
Any ideas what I can do to fix this? Thanks
  1 件のコメント
Walter Roberson
Walter Roberson 2015 年 11 月 9 日
Are you storing the code in foodwastes.m in a directory that is on your MATLAB path?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by