필터 지우기
필터 지우기

error in the matrix

조회 수: 1 (최근 30일)
abdalrhman hassan
abdalrhman hassan 2018년 1월 29일
댓글: abdalrhman hassan 2018년 1월 29일
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
  댓글 수: 1
Jan
Jan 2018년 1월 29일
Please mark the code and press the "{} Code" button. Currently the code is not readable.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 29일
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.
  댓글 수: 3
Walter Roberson
Walter Roberson 2018년 1월 29일
Assign
j = 0;
before
for Theta=0:5:360
and where you have k=k+1 add in j=j+1;
I suspect some of your variables are effectively duplicates of each other.
abdalrhman hassan
abdalrhman hassan 2018년 1월 29일
yes it should be try and error but i didn’t finsh yet i should use while loop but i can’t seem to remember how it work,thank you so much

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by