From: Erik L on
Hello,

Lets i have a matrix :
X =

2 8 6
3 2 6
9 4 3

I my algorithm, i am going to set a condition i-e, i take an element(lets say 2) from a column(col1) and want to see the difference between the current element and all other entries in the same column. If it is less than or equal to 2, i do something(if condition).

I tried it but the problem with for loop is, that col1-col1=0 so my condition always become true when comparision reaches to the point of the same element.

for example when X(2,1)=3 is being selected for comparision, my loop iterates and it compares X(2,1) with itself and take the difference=0. I want to avoid the element which is being selected currently for comparision in the loop.

Please Help

tak
Erik L.
From: Md Sahidullah on
Dear Erik,

Make a condition using ~ and &. It will solve your problem.

Simple try it!

:)

Thanking You.

Yours Sincerely,
Sahidullah


"Erik L" <lookgrn(a)gmail.com> wrote in message <huln6t$neo$1(a)fred.mathworks.com>...
> Hello,
>
> Lets i have a matrix :
> X =
>
> 2 8 6
> 3 2 6
> 9 4 3
>
> I my algorithm, i am going to set a condition i-e, i take an element(lets say 2) from a column(col1) and want to see the difference between the current element and all other entries in the same column. If it is less than or equal to 2, i do something(if condition).
>
> I tried it but the problem with for loop is, that col1-col1=0 so my condition always become true when comparision reaches to the point of the same element.
>
> for example when X(2,1)=3 is being selected for comparision, my loop iterates and it compares X(2,1) with itself and take the difference=0. I want to avoid the element which is being selected currently for comparision in the loop.
>
> Please Help
>
> tak
> Erik L.