Q: Problem importing two sparse arrays from a .mat file (Update)
- To: mathgroup at smc.vnet.net
- Subject: [mg107567] Q: Problem importing two sparse arrays from a .mat file (Update)
- From: Claudius Schnörr <Claudius.Schnoerr at gmx.de>
- Date: Wed, 17 Feb 2010 07:03:26 -0500 (EST)
Hello, how can two sparse arrays be read from a .mat file? (My Mma version is 7.0.1 on windows) (The .mat files are version 5) An example creating some .mat files in the other system: A = [ 0, 12, 13; 21, 0, 0; 0, 32, 0]; % a (3x3)-matrix H = sparse(A); H2 = sparse(A); save( 'test_A.mat', 'A' ); % file with a dense matrix save( 'test_H.mat', 'H' ); % file with a sparse matrix save( 'test_H2.mat', 'H' ); save( 'test_H2.mat', '-append', 'H2' ); % with two sparse matrices Reading them in Mma: A = Import["test_A.mat", "Data"][[1]]; MatrixForm[A] Head[A] (*a List*) H = Import["test_H.mat", "Data"][[1]]; MatrixForm[H] Head[H] (*a SparseArray*) How can multiple sparse arrays be read? The following doesn't work! H2 = Import["test_H2.mat", {"Data", {"SparseArray", "SparseArray"}}]; MatrixForm[H2] Head[H2] I expected a List of two SparseArrays in H2. Simply reading by H2=Import["test_H2.mat"] doesn't work either. Is this a bug or do I use the wrong syntax? The files can be downloaded here if you can't create the .mat-files yourself: http://www.lrz-muenchen.de/~schnoerr/LabCVME/Download/SparseArray_Import.zip Any help is welcome. ClS