Hi Jason,
Ok. I am assuming some things. I assume that you are a very basic and new user of MATLAB. So The code which I am giving is an extremely basic code just to give you a feel of the steps. There can be more optimized and complicated and slick codes but I have made this basic code for you for your understanding.
a(:,1) = randi(1000,[1,100]);
a(:,2) = randi(5000,[1,100]);
a(:,3)= randi(20000,[1,100]);
[p,q] = sort(a(:,1),'descend');
a(:,[1:end]) = a(q,[1:end]);
work1 = [];
work2=[];
work3=[];
for i = 1: size(a,1)
if a(i,2)+a(i,3)>2000;
work1= horzcat(work1,a(i,1));
else
if a(i,2)+a(i,3)<2000 && a(i,2)+a(i,3)>1000
work2 = horzcat(work2,a(i,1));
else
work3=horzcat(work3,a(i,1));
end
end
end
Of Course the number of if statements involved would be large depending upon the constraints and their inter-relationships. In Pattern Recognition also we work on large number of constraints and in many cases it is impossible to escape the if-else statements. Dont be afraid of them. In some cases you may reduce the number of if-else statements but it takes luck and conditions. I hope this code would give you an idea of the problem. I hope I have captured ur problem and given u an apt reply. If you need more help, mail back
Happy to Help
UJJWAL
Best Answer