my matlab program is showing this error Subscript indices must either be real positive integers or logicals what should i do below i have given my code
Show older comments
%calculation of performance of supercritical co2 brayton cycle % calculation of cp for different temp of s-co2 T=[300:0.1:1000]; cp=3.97*10^(-16)*T.^5-4.6654*10^(-12)*T.^4+2.1946*10^(-8)*T.^3-5.2823*10^(-5)*T.^2+0.06849*T+21.018; cpnew=mean(cp); Rco2=0.188954; %calculation of gama of sco2 cv=cpnew-Rco2; gamaco2=cpnew/cv; a=(gamaco2-1)/gamaco2; %calculation of different parameters of cycle %rp is pressure ratio %T1 is compressor inlet temperature(K) %T3 is turbine inlet temperature(K) %EHTR and ELTR is efficteveness of heat exchanger %IC1,IC2 and IT is isentropic eficcency of compressor and turbine %Q is amount of heat added(KW) %XMASS is amount of fraction of mass pass through the first compressor rp=3.387; T1=308; T3=523; IC1=0.88; IC2=0.87; IT=0.93; EHTR=0.925; ELTR=0.925; XMASS=0.5; Q=10000; %calculation of temperature of state point 2 T2=T1*(rp)^(a); TS2=T1+IC1(T2-T1); %calculation of temperature of state point 4 T4=T3/(rp)^(a); TS4=T3-IT(T3-T4); %calculation of other state point temperature T5=T3-Q/cpnew; T8=(T5-EHTR*T4S)/(1-EHTR); T9=T4S+(T8-T5); T7=T_2+ELTR(T9-TS2); T6=T9-XMASS(T7-TS2); T10=T6*(rp)^(a); TS10=T6+IC2(T10-T6); %calculation of net work output and efficency of cycle %WT is work done by turbine %WC1 and WC2 is work done by compressor1 and compressor2 %WNET is net work output of cycle %EFF is efficency of cycle %Mass flow rate in the cycle is 1kg/sec WT=cpnew(T3-TS4); WC1=XMASS*cpnew*(TS2-T1); WC2=(1-XMASS)*cpnew*(TS10-T6); WNET=WT-(WC1+WC2); EFF=WNET/cpnew*(T3-T5);
Answers (1)
Star Strider
on 30 Jul 2018
Since IC1 is a scalar, I suspect that you do not want to subscript it anyway. I have no idea what you are doing, so I assume that you may want to multiply it instead:
TS2=T1+IC1*(T2-T1);
See if that does what you want. (There are several other lines in your code that will likely throw the same error as you fix the previous ones, so you may want to change those as well.
To explain the error, subscripts in MATLAB must be integers greater than zero.
Categories
Find more on Engines & Motors in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!