Subscript indices must either be real positive integers or logicals.
1 次查看(过去 30 天)
显示 更早的评论
I am running this code an keep hitting this error when running the code. It occurs in line 36. The suggestions said it is matrix or vector related so i have indexed and called any variable as a constant yet it still occurs.
Pc = 2.74e6;
Tc = 530.3;
count=0;
yellow=0;
T = [100:.1:1000];
Pr = [0.02, 0.50, 1.0, 2.0];
P = Pc.*Pr;
V = 1:length(T);
acen = .333;
R = 8.3145;
b = 0.0778*R*Tc/Pc;
Cp_IG = (1:length(T));
colors = ['y' 'm' 'r' 'c'];
colorindx = 1;
hold on;
for Puse = P
n = 1;
Cp = 1:length(T);
yellow=yellow+1;
for Tuse = T;
a =3.243943838*(1.858281421-0.3727046432e-1*sqrt(Tuse))^2 ;
Vest1 = R*Tuse/Puse;
Vest2 = R*Tuse/(Puse+(a/(Vest1*(Vest1 + b)+b*(Vest1-b))))+b;
while abs((Vest1-Vest2))/Vest1 > .0001
Vest1 = Vest2;
Vest2 = R*Tuse/(Puse+(a/(Vest1*(Vest1 + b)+b*(Vest1-b))))+b;
end
t=abs(Tuse);
V(n) = Vest2;
v=abs(Vest2)
ts=sqrt(t);
count=count+1
if v>.00014;
z= -t*(8.314/(v-0.1251897785e-3)+(.1209032931*(1.858281421-0.3727046432e-1*sqrt(t)))/((v(v+0.1251897785e-3)+0.1251897785e-3)*sqrt(t)))^2/(-8.314*t/(v-0.1251897785e-3)^2+3.243943838*(1.858281421-0.3727046432e-1*sqrt(t))^2*(v+0.1251897785e-3)/(v(v+0.1251897785e-3)+0.1251897785e-3)^2)+t*(8.314000000*ln(v-0.1251897785e-3)-(.40274*(sqrt(t)*atan(89.3763*v+0.55945e-2)-49.8594*atan(89.3763*v+0.55945e-2)))/sqrt(t))-12.253+.8642*t-0.6289e-3*t^2+1.836000000*10^(-7)*t^3;
x= 0;
c= 0;
Cp(n)=z+x+c;
else
Cp(n)=0;
end;
n = n+1;
end;
semilogy(T, Cp, colors(colorindx));
colorindx = colorindx+1;
end;
1 个评论
Jan
2013-12-4
Which one is "line 36"? Please do not let us count lines, when you have this information directly available in the error message.
采纳的回答
sixwwwwww
2013-12-4
replace line 36 with the following line:
z= -t * (8.314 / ( v - 0.1251897785e-3) + (.1209032931 * (1.858281421 - 0.3727046432e-1 * sqrt(t))) / ((v * (v + 0.1251897785e-3) + 0.1251897785e-3) * sqrt(t)))^2 / (-8.314 * t / (v - 0.1251897785e-3)^2 + 3.243943838 * (1.858281421 - 0.3727046432e-1 * sqrt(t))^2 * (v + 0.1251897785e-3) / (v * (v+0.1251897785e-3)+0.1251897785e-3)^2)+t*(8.314000000*log(v-0.1251897785e-3)-(.40274*(sqrt(t)*atan(89.3763*v+0.55945e-2)-49.8594* atan(89.3763*v+0.55945e-2)))/sqrt(t))-12.253+.8642*t-0.6289e-3*t^2+1.836000000*10^(-7)*t^3;
you were making few syntax mistakes in it
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Web Services 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!