Azzera filtri
Azzera filtri

Displaying string with variables

1 visualizzazione (ultimi 30 giorni)
Rick
Rick il 9 Nov 2015
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 Commento
Walter Roberson
Walter Roberson il 9 Nov 2015
Are you storing the code in foodwastes.m in a directory that is on your MATLAB path?

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Characters and Strings 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