# matrix multiplication error

57 views (last 30 days)
Fred on 7 Mar 2012
Commented: ferda sonmez on 21 Mar 2019
Hi all,
i'm doing matrix multiply and array multiply but it gives me NaN matrix what can be the reason for that? this is the equation a=xv*eye(n).*xv

#### 1 Comment

ferda sonmez on 21 Mar 2019
Hi,
I have thw saame issue. My matrixes do not have NaN values, however, multiplication of the matrixes has NaN values? Is this situation is acceptable or am I missing something?

Walter Roberson on 7 Mar 2012
You could get NaN if you multiply infinity by 0. Once you have one NaN, it very often "pollutes" all the other calculations.

Fred on 7 Mar 2012
i'm guessing probably i am not suppose to have infinity but my matrix is 24x2100 size so should i check all elements by one by if it they are infinity or not?
is there any other easy way to do that?
Walter Roberson on 7 Mar 2012
any(isfinite(Matrix(:)))
will be true if there are any infinite values.
Be sure to also check
any(isnan(Matrix(:)))
which will be true if there are any NaN values.