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!