I cant get this matlab function to work.

2 ビュー (過去 30 日間)
Rodrigo Blas
Rodrigo Blas 2018 年 12 月 2 日
コメント済み: madhan ravi 2018 年 12 月 2 日
I have to use fsolve() to call this function.
I want to input a guess for fsolve() and I want two answers for each of the equations for Rblas4(1) and Rblas4(2).
my error reads:
error: 'T' undefined near line 19 column 18
error: called from
arco at line 19 column 14
My script it:
function Rblas4=arco(T)
p=51;
v=35;
n=50;
r=.08206;
spv=v/n;
Tca=150.87;
wa=1.002;
Tcc=304.2;
Pcc=72.9;
Pca=48.3;
wc=.225;
aa=.42747*((r*Tca)^2/Pca);
ac=.42747*((r*Tcc)^2/Pcc);
ba=.08664*((r*Tca)/Pca);
bc=.08664*((r*Tcc)/Pcc);
ma=.48508+1.55171*wa-.1561*(wa-1)^2;
mc=.48508+1.55171*wc-.1561*wc^2;
RBlas4(1)=(r*T(1))/(spv-ba)-aa*(1+ma*(1-sqrt(T(1)/Tca)))^2/(spv*(spv-ba))-p;
RBlas4(2)=(r*T(2))/(spv-bc)-ac*(1+mc*(1-sqrt(T(2)/Tcc)))^2/(spv*(spv-bc))-p;
end
THANK YOU

採用された回答

madhan ravi
madhan ravi 2018 年 12 月 2 日
編集済み: madhan ravi 2018 年 12 月 2 日
EDITED
You should call the function properly with input T like shown below:
T=[3 8] %example
Rblas4=arco(T) %function call
function RBlas4=arco(T) %function definition
p=51;
v=35;
n=50;
r=.08206;
spv=v/n;
Tca=150.87;
wa=1.002;
Tcc=304.2;
Pcc=72.9;
Pca=48.3;
wc=.225;
aa=.42747*((r*Tca)^2/Pca);
ac=.42747*((r*Tcc)^2/Pcc);
ba=.08664*((r*Tca)/Pca);
bc=.08664*((r*Tcc)/Pcc);
ma=.48508+1.55171*wa-.1561*(wa-1)^2;
mc=.48508+1.55171*wc-.1561*wc^2;
RBlas4=[(r*T(1))/(spv-ba)-aa*(1+ma*(1-sqrt(T(1)/Tca)))^2/(spv*(spv-ba))-p; %change this line too
(r*T(2))/(spv-bc)-ac*(1+mc*(1-sqrt(T(2)/Tcc)))^2/(spv*(spv-bc))-p];
end
Note: matlab is case sensitive Rblas4 should be RBlas4
  9 件のコメント
Rodrigo Blas
Rodrigo Blas 2018 年 12 月 2 日
got it! THANK YOU SO MUCH!
What happened is I didnt click run.
You were very helpful :)
madhan ravi
madhan ravi 2018 年 12 月 2 日
Anytime :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResampling Techniques についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by