Prev: LeGall 5/3 Wavelet
Next: ASYMMETRIC ENVELOPE DETECTOR
From: mat001 on 13 Aug 2010 07:08 I have a 2d matrix and i want to set something like that if any element of matrix will be greater than maximum value (let say 50) then error how to do that Please reply me soon. Regards
From: Sean on 13 Aug 2010 08:40 "mat001 " <priya.biomath(a)yahoo.co.in> wrote in message <i4392l$2is$1(a)fred.mathworks.com>... > I have a 2d matrix and i want to set something like that > > if any element of matrix will be greater than maximum value (let say 50) then error > > how to do that > > Please reply me soon. > > Regards if(any(matrix>50)) error('Ha!'); end
From: Walter Roberson on 13 Aug 2010 09:21 Sean wrote: > "mat001 " <priya.biomath(a)yahoo.co.in> wrote in message > <i4392l$2is$1(a)fred.mathworks.com>... >> I have a 2d matrix and i want to set something like that >> >> if any element of matrix will be greater than maximum value (let say >> 50) then error >> >> how to do that >> >> Please reply me soon. >> >> Regards > > if(any(matrix>50)) > error('Ha!'); > end Sean, the original poster indicated that it was a 2D matrix. matrix > 50 would result in a 2D matrix of logical values any() applied to that would result in a row vector of logical values "if" applied to that would be the same as "if all(...)" and so would test if *all* of the columns had at least one value greater than 50. The easiest fix to this is if any(matrix(:)>50))
From: Sean on 13 Aug 2010 09:57 Walter Roberson <roberson(a)hushmail.com> wrote in message <UFb9o.59107$dx7.43323(a)newsfe21.iad>... > Sean wrote: > > "mat001 " <priya.biomath(a)yahoo.co.in> wrote in message > > <i4392l$2is$1(a)fred.mathworks.com>... > >> I have a 2d matrix and i want to set something like that > >> > >> if any element of matrix will be greater than maximum value (let say > >> 50) then error > >> > >> how to do that > >> > >> Please reply me soon. > >> > >> Regards > > > > if(any(matrix>50)) > > error('Ha!'); > > end > > Sean, the original poster indicated that it was a 2D matrix. > matrix > 50 would result in a 2D matrix of logical values > any() applied to that would result in a row vector of logical values > "if" applied to that would be the same as "if all(...)" and so would > test if *all* of the columns had at least one value greater than 50. > > The easiest fix to this is > > if any(matrix(:)>50)) That is correct, sorry.
|
Pages: 1 Prev: LeGall 5/3 Wavelet Next: ASYMMETRIC ENVELOPE DETECTOR |