|
"Wayne King" <wmkingty@gmail.com> wrote in message <hv507r$1pa$1@fred.mathworks.com>...
> "Erik L" <lookgrn@gmail.com> wrote in message <hv4vks$ogs$1@fred.mathworks.com>...
> > I have a matrix A=[0 2 3 4 3 1 0]
> >
> > I want to check each element of A in if condition:
> >
> > if ANY element is greater than or equal to 2, my condition is false.
> >
> > I don't want to use the following code:
> >
> > If(A(1,1)<2 && A(1,2)<2 && A(1,3)<2 && A(1,4)<2.........
> >
> > .....
> >
> >
> > Is there any alternative, because i have a very huge row vector.
> >
> > thanks
> >
> > Erik
>
> Hi Erik,
>
> A = [0 2 3 4 3 1 0];
> if (any(A>2))
> disp('There is an element greater than 2.');
> else
> disp('No element is greater than 2');
> end
>
>
> Wayne
Thanks Wayne
If my condition is if all elements are <2, what will be the exact code.
Cheers
Erik
|