Read .mat file in android?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Is it possible to read .mat file in android ? how should I convert .mat file to java readable format?
0 commentaires
Réponses (2)
Kaustubha Govind
le 11 Avr 2012
You can write C code using the MAT-file libraries to read MAT-files outside of MATLAB - see Read and Write MATLAB MAT-Files in C/C++ and Fortran. You can then call this C code from Android/Java using JNI.
Alternately, you could use MATLAB to load the MAT-files and write the data inside them into a text-file (using one of the text-file related functions). You should be able to find Java file I/O functions that can read these text files. (Full disclosure, I am not a Java programmer, so can't give specific advice)
0 commentaires
Eric
le 11 Avr 2012
Here's another possibility: when saving the MAT file, use the -v7.3 option. Then the MAT file is actually an HDF5 file. You can use tools from the HDF Group to work with these files natively in Java and not have to resort to C/C++. See
Good luck,
Eric
9 commentaires
Eric
le 12 Avr 2012
I'm wondering now if I actually previously selected a non-HDF5 MAT file for opening in HDFView. The ones I try opening now work fine.
Furthermore, I've been able to save data with the -v7.3 switch and read values back in using h5read(). Of course that's still in Matlab and perhaps h5read() is smart enough to know that it's a "modified" HDF5 file.
So I changed the extension of the file from MAT to h5. Mathematica's HDF5 import tool cannot open the file.
So interestingly enough, Matlab and HDFView 2.6.1 can both read values from a MAT file saved with -v7.3. Mathematica apparently cannot. Whether or not Java tools from the HDF Group (which makes HDFView) is perhaps still an open question.
Malcolm Lidierth
le 13 Avr 2012
@Eric
h5read is a high-level MATLAB specific API but if HDFView handles the file OK there would seem to be no problem at the MATLAB end.
Plainly, generic HDF5 functions can not be expected to fully interpret the MATLAB-specific contents of a v7.3 file e.g. MATLAB objects, function-handles etc.
My initial support request related to using a low-level MATLAB HDF5 API function on a v7.3 file, which should, given the file contents, have returned an error code but instead threw an error and terminated.
For my money, v6 is by far the best MAT-file format and TMW should update that to include unicode and 64 bit - implementing compression on the data - not the metadata as well - as a user-selectable option.
Voir également
Catégories
En savoir plus sur Text Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!