Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Handling with different constraints/limitations at the same time

1 vue (au cours des 30 derniers jours)
Rengin
Rengin le 29 Jan 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
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

Réponses (0)

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by