필터 지우기
필터 지우기

Subscript indices error when not running a loop

조회 수: 4 (최근 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 CenterFile Exchange에서 Conversion 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