error in my code
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
clear
R=1000*[5, 100, 200, 250];
v1=100;
A=[R(1),0,0,R(4),0;...
0,R(2),0,-R(4),R(5);...
0,0,R(3),0,-R(5);...
1,-1,0,-1,0;...
0,1,-1,0,1];
A=inverse(A);
v2=50;
B=[v1;0;-v2;0;0];
I_t=A*B;
K=1;
while transpose(I_t)< 0.0001*ones(1,5) & transpose(I_t)>=zeros(1,5)
I=I_t;
v2=v2+0.1;
B(3)=-v2;
I_t=A*B;
K=K+1;
end
v_max=v2 %max v2
v2=50;
B=[v1;0;-v2;0;0];
I_t=A*B;
K=1;
while transpose (I_t)< 0.0001*ones(1,5) & transpose(I_t)>=zeros(1,5)
I=I_t;
v2=v2-0.1;
B(3)=-v2;
I_t=A*B;
K=K+1;
end
v_min=v2 %min v2
Im having a problem in line 6 it says Index exceeds the number of array elements (4).
I need help please
0 个评论
回答(1 个)
Star Strider
2020-10-27
The way you coded ‘R’:
R=1000*[5, 100, 200, 250];
it only has 4 elements. Nothing exists beyond ‘R(4)’.
0 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!