Index exceeds array bounds
이전 댓글 표시
Rho = 997;
g = 9.8;
Le =115.25 ;
Ae =214.4 ;
Ac =51.5 ;
Li =172;
Ai =84.13;
Di = (Ae/Ac)^2 - 1;
S = Ac;
beta2 = 14.3*(%pi/180);
w=92.3*(2*%pi)/60;
R=4;
U2 = w*R;
Head=114;
alfa = 1.3;
zt2 = 0.29;
ztT=34.47;
Qm=740;
n=20;
Xv=logspace(0,3,n)*1e-3;
Cv=logspace(0,4,n)*1e-6;
Sol=zeros(2,n);
%%%%
Cav = 0;
for h=1:n
X=-Xv(h);
for i=1:n
Cc=Cv(i);
Eq=(Rho*Qm*(zt2-Di)/Ae^2)-((y^2)*Rho*X*(Li/Ai))-(Rho*Qm*(ztT/Ai^2))+Cc*(2*Rho^2*(y^2)*((cot(beta2))/S)*(((cot(beta2))/S)*Qm-U2)*(Le/Ae)+Rho^2*(Li/Ai)*(y^2)*Qm*((Di-zt2)/Ae^2)-(y^2)*(Rho^2)*(Le/Ae)*(ztT/Ai^2)*Qm)+Cav*(2*(Rho^2)*(y^2)*((cot(beta2))/S)*(((cot(beta2))/S)*Qm-U2)*(Le/Ae)+(Rho^2)*(Li/Ai)*(y^2)*Qm*((Di-zt2)/Ae^2)-(y^2)*(Rho^2)*(Le/Ae)*(ztT/Ai^2)*Qm); %%EQUAÇÃO CARACTERÍSTICA
Sol(:,i)=double(vpasolve(Eq,y)); % SOLUÇÃO DA EQ. CARACTERÍSTICA
Wr(h,i)= Eq(Sol(2,i));
I need to apply the result i get from vpasolve back in Eq so I can determinate if Wr is positive or negative and plot a graphic with it.
I am trying to plot a graphic with the solution, however in the last line I always get "Index exceeds array bounds"
댓글 수: 5
Adam
2018년 10월 10일
Is there any guarantee that the result of a vpasolve of an equation will be a valid index into the Eq variable? It seems unlikely, but I don't use vpasolve so I wouldn't really know.
Bob Thompson
2018년 10월 10일
What are the sizes of Eq, and Sol, and the value of i when it errors?
madhan ravi
2018년 10월 10일
upload all the missing datas
Alysson Guimarães
2018년 10월 10일
Adam
2018년 10월 10일
You are using the result of this complex cubic equation to index into a scalar though. This makes no sense! I don't know what you are attempting to do with
Eq( Sol(2,i) )
but since Eq is a scalar then unless Sol(2,i) evaluates to 1 every time (in which case it is pointless) then it will error.
채택된 답변
추가 답변 (1개)
Jan
2018년 10월 10일
0 개 추천
If Eq is a scalar, a 1x1 array, than the only working value of Sol(2,i) is 1. Otherwise Eq(Sol(2,i)) must fail, of course.
We cannot run the code due to the missing data, and cannot guess, what the code should do due to the lack of comments and explanations. It is not clear which variables are symbolic and which are numerical. Maybe you have redefined cot as an array?
카테고리
도움말 센터 및 File Exchange에서 Equation Solving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!