Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have two matrices A1 and A2 in HDF format. I use the following code to import them.

A1 = Import[
  "http://www.math.mtu.edu/~struther/Courses/4610/Data/A1.hdf", "Data"];`

When I type Dimensions[A1] I get the output

{1, 12, 10}

Now, I want to do the Singular Value Decomposition on A1 and reconstruct it from the output matrices. I can do the SVD, but when I check the original and reconstructed matrix by inputting A1 - U.W.Transpose[V], I get a shape not matching error. Also, when I see A1 in MatrixForm, I see a matrix with each column as a separate vector(column matrix) inside the big matrix.

{U, W, V} = SingularValueDecomposition[A1];
Norm[A11 - U.W.Transpose[V], 2]


Here's a screenshot of A1 in MatrixForm

enter image description here

I can't figure out why there are separate columns inside the matrix. Also there are 10 rows and 12 columns, but Dimensions[A1] outputs

{1, 12, 10}

Any help would be greatly appreciated.

share|improve this question

1 Answer 1

Try...

A1 = Import["http://www.math.mtu.edu/~struther/Courses/4610/Data/A1.hdf", "Data"][[1]];

My assumption (not being able to try this) is that Import is returning you a list of things in the file of which A1 is the first.

BTW: Try not to use capital letters (especially single capitals) as some are reserved symbols in Mathematica (like D and E).

share|improve this answer
    
It works!! Thanks a lot! –  Koustubh Gohad Mar 10 at 16:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.