Subscript indices error when not running a loop

2 ビュー (過去 30 日間)
Vidhan Malik
Vidhan Malik 2016 年 4 月 15 日
コメント済み: Vidhan Malik 2016 年 4 月 16 日
Running this code and I don't have any loops or matrices so am really confused why I am getting the error
"Subscript indices must either be real positive integers or logicals."
I tried debugging it to see if the error might be occurring due to the vpa solve function since there are actually two roots but I am only using the positive answer. So I replaced that line with R=1 and that error still remains.
clear; clc;
syms R
To7 = 1200;
To6 = 1800;
Ya = 1.4/0.4;
Ym = 1.35/0.35;
Yc = 1.3/0.3;
Rg = 0.287;
Qr = 45e3;
T32 = 276;
PrT = (To7/To6)^(Yc/0.92); %Step 1
PrC = 1/(0.97*0.99^3*PrT*0.975*0.98); %Step 2
To4 = 276*PrC^(1/(0.9*Ym)); %Step 3
To5 = 0.92*(To7 - To4) + To4; %Step 4
fostoic = 14/(1.5*(32+3.76*28));
fo = 0.9*fostoic; %Step 5
E = (1+R)*(Ym*Rg)*To5 + fo/(1+R)*Qr == (1+R+fo/(1+R) - 0.12*(1+R))*Yc*Rg*To6;
R = vpasolve(E,R,[0 Inf]); %Step 6
Wnet = (1+R+fo/(1+R) - 0.12*(1+R))*Yc*Rg*(To6-To7) - (1+R)*Ym*Rg(To4-T32);
disp(Rg);

採用された回答

Ced
Ced 2016 年 4 月 15 日
編集済み: Ced 2016 年 4 月 15 日
You are missing a * (or some other operation) after Rg in the second to last row (where the error occurs). It should be
Wnet = (1+R+fo/(1+R) - 0.12*(1+R))*Yc*Rg*(To6-To7) - (1+R)*Ym*Rg*(To4-T32);
Cheers
  1 件のコメント
Vidhan Malik
Vidhan Malik 2016 年 4 月 16 日
wow... can't believe I missed that. Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by