compare elements in a column and exit while loop

hi,
i have two matrices, each of size 2xn and 2xm. i would like to select one column from each of these matrices and compare its elements. now even if any one of the elements meet the condition then i would like to exit a while loop. for example-
A=[a11 a12; a21 a22]
B=[b11 b12 b13; b21 b22 b23]
now i want to find the difference the first columns of each of the matrices. meaning (a11 vs b11) and (a21 vs b21). now if any one of these two results is below a certain value then i would like to exit the while loop.

1 Comment

Jan
Jan on 11 May 2018
Edited: Jan on 11 May 2018
"if any one of the elements meet the condition" - which condition? What is "a11, a12, ..."? Are they numbers or objects or symbolic variables?
Do you have 1 or 2 while loops?
"select one column from each of these matrices and compare its elements" - which column? Compare the elements by which operation? greater, greater equal, lower, lower equal, equal, opposite signs, higher absolute value? Please be more specific.

Sign in to comment.

 Accepted Answer

Perhaps with some guessing:
A = rand(2, 2);
B = rand(2, 3);
% For the 2nd while loop:
while ???
if any(A(:, 1) - B(:, 1) < Limit)
break;
end
end
I do not have an idea for the 1st part, because it is not clear which column you want to choose and how you want to "compare" the values.

2 Comments

hello sir! i have an array having two column. array holds number of data with their priority 1 to 10(higher value means higher priority ) and know I have to put the data of this array according to their priorities into an another arrays . basicalyy 3 diffrent arrays of different size one array has limit 20 to hold data other has length 30 and the last array has the capacity to hold data is 40. these arrays have some values already in it. these array also have two columns (1st coulmn hold data in its 2nd column shows lru number 1 to 7 of that particular data . now I HAVE to evict the least recently used data having lru<7 and replace it with the data of an element with higher priority one by one using loops.
we can say from one main array we have to get value and then replece it with the others arrays value with less lru number .
main array may contain 1000 number of data with their priority number... basically all arays has same column number but different length.
please help me how to do that . i have done these steps through matlab build in command but I want to use loop because when large ammount of data is arrived then its not possible for me to put data one by one to kindly help me out to do that.
@Saira: Please do not attach a new question as a comment to an answer to another question. Open a new thread instead and romove this message. Thanks.

Sign in to comment.

More Answers (0)

Categories

Asked:

fk
on 11 May 2018

Commented:

Jan
on 16 Feb 2023

Community Treasure Hunt

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

Start Hunting!