MATLAB: Error in the matrix

matrixmatrix manipulation

hey guys when i try to run the program it tell me excced number of matrix in line 41 i want to draw p in y axis with V in x axis thank you
clc;clear;
B=79.21
a=30.835
L=83.919
j=0
k=0
n=0
f=0
i=0
P_i=6
RPM=300
d_time=(5/360)*(60/RPM)
p(k+1)=.99*(P_i)
p(k+2)=.9*p(1)
T(f+1)=290
R=.287
V(1)=27*1000
c_d=.6
h=8
Tw=290
cp=1.005
m(n+1)=p(1)*V(1)/(R*T(1))
for Theta=0:5:360
i=i+1
j=j+1
x(i)=a*cos(Theta)+sqrt((((L*L)-(a*a)*(sin(Theta))^2)))
V(j)=(pi/4)*(B^2)*(x(i))+(27*1000)
end
for Theta=0:5:360
n=n+1
k=k+1
f=f+1
rho=(p(k)+p(k+1))./(2*R*T(f))
if (Theta <=120)
d_Mi=c_d*(pi/4)*((.3)^2)*sqrt(2*rho.*(p(k)-p(k+1)))
m(n+1)=m(n)+d_Mi
T(f+1)=(d_time*h*pi*B*x(i).*(2*Tw-T(f))-(p(k)+p(k+1)).*(V(j+1)-V(j))+2*m(n)*cp*T(f))./(2*m(n+1).*cp+(d_time*h*pi*B.*x(i)))
p(k+1)=m(n+1).*R*T(f+1)./(v(j+1))
end
if (Theta >=160) && (Theta <=300)
d_Me=c_d*(pi/4)*((.28)^2)*sqrt(2*rho*(p(k)-p(k+1)))
m(n+1)=m(n)-d_Me
T(f+1)=(d_time*h*pi*B*x(i)*(2*Tw-T(f))-(p(k)+p(k+1))*(V(j+1)-V(j))+2*m(n)*cp*T(f))/(2*m(n+1)*cp+(d_time*h*pi*B*x(i)))
p(k+1)=m(n+1)*R*T(f+1)/(v(j+1))
end
if (Theta >=300) && (Theta <=360)
m(n+1)=m(n)
T(f+1)=(d_time*h*pi*B*x(i)*(2*Tw-T(f))-(p(k)+p(k+1))*(V(j+1)-V(j))+2*m(n)*cp*T(f))/(2*m(n+1)*cp+(d_time*h*pi*B*x(i)))
p(k+1)=m(n+1)*R*T(f+1)/(v(j+1))
end
if (Theta >120) && (Theta <160)
m(n+1)=m(n)
T(f+1)=(d_time*h*pi*B*x(i)*(2*Tw-T(f))-(p(k)+p(k+1))*(V(j+1)-V(j))+2*m(n)*cp*T(f))/(2*m(n+1)*cp+(d_time*h*pi*B*x(i)))
p(k+1)=m(n+1)*R*T(f+1)/(v(j+1))
end
end

Best Answer

Your code
j=0
for Theta=0:5:360
i=i+1
j=j+1
x(i)=a*cos(Theta)+sqrt((((L*L)-(a*a)*(sin(Theta))^2)))
V(j)=(pi/4)*(B^2)*(x(i))+(27*1000)
end
will leave j as 73 and V as length 73.
Your line
T(f+1)=(d_time*h*pi*B*x(i).*(2*Tw-T(f))-(p(k)+p(k+1)).*(V(j+1)-V(j))+2*m(n)*cp*T(f))./(2*m(n+1).*cp+(d_time*h*pi*B.*x(i)))
has V(j+1)-V(j) which tries to access V(73+1)-V(73) but V(74) does not exist.