Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Alan
Posts:
151
Registered:
7/24/09


Re: how to distinguish inf and inf
Posted:
Oct 12, 2010 6:38 PM


"Nils Tobias " <nils.kraemer@uniulm.de> wrote in message <i92n63$ljq$1@fred.mathworks.com>... > Thanks Alan, that's true but sorry I still don't know how to put those pieces together. > > I have a vector x = [inf 2 3 inf] > > and isinf(x) tells me [1 0 0 1] > > How to get isinf_me(x) that gives me back [1 0 0 1] > > I mean 1 and +1 is not necessary any other positive respectively negative number would do. > > Thanks > NTK > > > > > Is there any builtin function? > > > > > > NTK > > > > >> inf>0 > > ans = > > 1 > > >> inf>0 > > ans = > > 0
You can create these two vectors very easily:
isinf = isinf(x); % [1 0 0 1] sgn = (x>0)*21; % [1 1 1 1]
And hopefully the rest is obvious. Matlab also has a function called sign() that does essentially the same thing that second calculation does, and probably faster.



