Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

A1 = Import[
  "", "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


A1 = Import["", "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 '14 at 16:25

Your Answer


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.