Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Handling with different constraints/limitations at the same time

조회 수: 1 (최근 30일)
Rengin
Rengin 2016년 1월 29일
마감: MATLAB Answer Bot 2021년 8월 20일
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개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by