Info
This question is closed. Reopen it to edit or answer.
Handling with different constraints/limitations at the same time
    2 views (last 30 days)
  
       Show older comments
    
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 Comments
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!