for arbitrary ND array, you can use any(Y(:)~=4).  Ken
Rob Henson wrote in message <36137DF0.BAC52D32@mathworks.com>...
>Hi Arun,
>
>as Matt says, the not equal operator is "~=" . However in MATLAB it
>is an element wise operator so in Matt's example notice that some
>elements are 1s and others are 0s. This means that you must be
>careful with this sort of thing
>
>if a~=b
> do something
>else
> do something else
>end
>
>As the if operator is true only if all elements of the clause are not zero.
>So for Matt's example
>
>>> y=[1 2 3 4 4 4 5 6];
>
>This :
>
>if y~=4
> foo = 1
>else
> foo = 0
>end
>
>gives foo = 0, which may seem counter intuitive.
>
>
>To get the "expected" behaviour you need to use the 'any' operator
>
>if any(y~=4)
> foo = 1
>else
> foo = 0
>end
>
>gives foo =1
>
>For matrices rather than vectors, you will need any(any(Y~=4)).
>
>I hope that helps.
>
>Rob
>
>Matt Taylor wrote:
>
>> Arun,
>>
>> It works for me, using ver 5.2. Example:
>>
>> (I;(B y=[1 2 3 4 4 4 5 6]
>> y =
>> 1 2 3 4 4 4 5 6
>> (I;(B y~=4
>> ans =
>> 1 1 1 0 0 0 1 1
>>
>> Matt Taylor
>>
>> Arun Chhabra wrote in message <6uu6n7$s6i$1@dskd3.itg.ti.com>...
>> >*** To respond, remove "nospam" from the replyto address ***
>> >
>> >How do you represent "Not Equal To" in Matlab?? Something like the
>> >equivalent of "!=" in C.
>> >
>> >I know that NOT is "~", however the combined expression of "~=" did not
>> >work.
>> >
>> >I'd appreciate any suggestions...I'm using Matlab 4.0.
>> >
>> >Thanks in advance,
>> >Arun
>> >
>> >
>> >
>> >
>
>
>
>
>===========================================================
>Robert Henson Email  rob@mathworks.com
>The MathWorks, Inc. WWW  http://www.mathworks.com
>24 Prime Parkway Phone  (508) 6477505
>Natick, MA 01760 FAX  (508) 6477012
>===========================================================
>
>
