the following command returns how many Inf's are in a vector

length(find(myVector==Inf))

skip to main |
skip to sidebar
## Tuesday, January 29, 2008

###
count how many Inf's are in a vector

## other nice blogs

## Labels

just another blog. here you'll find my experiences with Matlab/Simulink, vba, LaTeX and Mac OS X.

the following command returns how many Inf's are in a vector

length(find(myVector==Inf))

Subscribe to:
Post Comments (Atom)

- announcements (1)
- best practice (1)
- carpetplot (3)
- cell array (1)
- colorbar (1)
- debug (2)
- excel (5)
- firefox (3)
- fourier (1)
- gds (1)
- label (1)
- latex (4)
- m-lint (1)
- mac (6)
- mathworks webinars (3)
- matlab (56)
- matlab GUI (2)
- matlab import (1)
- matlab plots (17)
- matlab subplots (2)
- matlab-tutorials (4)
- other (2)
- simulink (10)
- speeding up code (2)
- svn (1)
- thermodynamics (2)
- vba (10)
- video tutorial (1)
- warning (1)

## 2 comments:

Actually a faster way is this:

sum(isinf(myVector))

ah. yes. you are right. this is more elegant. but the long way may be easier to adapt to other requirements. for example, if you whant to count how many "2"s are in a row, or how many zeros.

thanks for the comment!

leg

Post a Comment