Subscript indices error when not running a loop

1 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by