Subscript indices error when not running a loop

1 vue (au cours des 30 derniers jours)
Vidhan Malik
Vidhan Malik le 15 Avr 2016
Commenté : Vidhan Malik le 16 Avr 2016
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);

Réponse acceptée

Ced
Ced le 15 Avr 2016
Modifié(e) : Ced le 15 Avr 2016
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 commentaire
Vidhan Malik
Vidhan Malik le 16 Avr 2016
wow... can't believe I missed that. Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Function Creation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by