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.


1 Answer 1



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).

  • $\begingroup$ It works!! Thanks a lot! $\endgroup$ Mar 10, 2014 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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