|
"Akim " <aaa@bbb.ccc> wrote in message
news:gl3j48$hc4$1@fred.mathworks.com...
> Dear all,
>
> My Matlab v7 (2005) matlab manual tells me that "Multiplication and
> division are performed on only the nonzero elements of sparse matrices".
> Such a set-up is very convenient for me.
>
> On my older Windows matlab 7.1.0.124 (R14) (August 2005), multiplication
> (division) works just like the manual says it should:
>
> EDU>> sparse([1 0 0 0 0])./0
> ans =
> (1,1) Inf
>
> But on a newer Linux matlab 7.5.0.338 (R2007b), the zero elements are also
> involved -- this is a big nuisance:
>
>>> sparse([1 0 0 0 0])./0
> ans =
> (1,1) Inf
> (1,2) NaN
> (1,3) NaN
> (1,4) NaN
> (1,5) NaN
>
> How could I revert to the old version of multiplication? If that's not
> possible, how could I use spfun with two matrix inputs ... spfun(@times,[2
> input matrices?]).
You can't revert to the old behavior, as it was a bug that was fixed in
MATLAB 7.2 (R2006a):
http://www.mathworks.com/support/bugreports/details.html?rp=245912
In order to do what you want with SPFUN, you'll need to write your own
function (which can be an anonymous function):
S = sparse([1 0 0 0 0]);
result = spfun(@(x) x./0, S)
--
Steve Lord
slord@mathworks.com
|