Info
此问题已关闭。 请重新打开它进行编辑或回答。
Handling with different constraints/limitations at the same time
1 次查看(过去 30 天)
显示 更早的评论
clear all
clc
% Dear Users!
% What I want to do is
% 1. As long as the rows of A, B and matrices are > 0 at the same time and
% C matrix > -7 separately, I want to take the summary of same rows in A
% and B to be put into objective matrix
% 2. When I come to the row in C matrix which is < - 7 I want to stop the
% iteration and see after how may iterations I can have an value ~=0
% 3. Objective matrix should be Objective=[14;10;-2;-5;-3;0;0]
% I want to be stuck on this code
% Thanks a lot
A=[8;6;-3;-2;1;5;6];
B=[6;4;1;-3;-4;-7;-9];
C=[2;0;3;6;-7;-8;-9];
nrow=7;
ncolumn=1;
Objective=zeros(1,ncolumn);
iteration=0;
flag1=0;
while flag1==0
flag1=1;
flag2=0;
while flag2==0
flag2=1;
for ii=1:nrow
for jj=1:ncolumn
if A(ii,jj)<0 || B(ii,jj)<0
flag1=0;
break
end
end
end
end
for ii=1:nrow
for jj=1:ncolumn
if C(ii,jj)< -7
flag2=0;
break
end
end
end
for ii=1:nrow
for jj=1:ncolumn
Objective(ii,jj)=A(ii,jj)+B(ii,jj);
iteration=iteration+1;
end
end
end
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!