Three Matrix Multipiclation Resulting Nan Value

Hello, this is my first time using Matlab, and now i'm using trial version. I've project to calculate do aggregation matrix in Leontif input-output analysis. I just want to multiplied three matrix in the same time, namely matix S(25x185), Z(185x185), and T(185x25). I multiplied by using command; >> N=S*Z*T when N is new aggregation matrix with size 25x25 dimension. But the result show me "nan" value. can somebody tell me what's wrong with my data/command/computer's memory, or this matrix size was too large. or can somebody help me calculate that's matrix for me, please? i've attach my file (IST.mat) file for detail.

 Accepted Answer

This has ABSOLUTELY NOTHING to do with the size of these matrices, which are actually pretty small. It has nothing to do with your computer memory.
LOOK AT YOUR DATA. When you see something like this, LOOK AT IT.
[I,J] = find(isnan(Z))
I =
73
J =
170
So we can find this:
Z(73,170)
ans =
NaN
NaNs propagate. Add anything to a NAN? Multiply by NaN? What do you get? A NaN.
So if we look at the matrix S*Z, we will find an entire row of NaNs.
spy(isnan(S*Z))
So if we look at column 120 of the product S*Z, it is entirely NaN. Right multiply that matrix by ANY other matrix, and ALL elements will be NaN. So S*Z*T will be entirely filled with NaNs.

1 Comment

Thankyou john, I got it. This would gonna be worth lesson to checking my data first with "isnan" command.
i've checked my original data in excel thats Nan must be "0". so how i can change this Nan value? do I have to CHhange it in excel or I can use syntax command for it?

Sign in to comment.

More Answers (1)

Your matrix Z has a NaN in it, as can be confirmed with the command
[i,j] = find(isnan(Z))

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!