[vsipl++] Reading individual variables from .mat file

Brooks Moses brooks at codesourcery.com
Sat Jul 25 00:06:58 UTC 2009


Hello!

bhanson wrote, at 7/24/2009 1:58 PM:
> I have a Matlab .mat file and am attempting to read multiple variables (or
> specify individual variables from a file containing multiple variables).
> However, using the examples under "Matlab IO" documentation I am only able
> to retrieve one variable (always the same one).  Any ideas?

Perhaps a better example to follow for Matlab IO with multiple variables
in a single file is the example in the testsuite, contained in
tests/vsip_csl/matlab/matlab_bin_file/matlab_bin_file.cpp.  For
reference, I've attached a copy.

When you first use operator>> on your std::ifstream object with a
Matlab_bin_formatter object, you will always retrieve the first variable
in the file.  If you then use it again on the same std::ifstream object
(without closing and reopening the file), you'll get the second
variable, and so forth.  The "name" argument is not used to locate the
variable within the file -- its purpose was only as a check to make sure
that the loaded variable corresponds to the programmer's expectations.

> Also, when attempting to use the 'iterator interface' example in the
> documentation, I get the following error...
> 
> erminate called after throwing an instance of 'std::runtime_error'
>   what():  Matlab_view_header(read): Unsupported data_element type: got
> miCOMPRESSED (15), can only handl miMATRIX (14)

Unfortunately, there are some known bugs with the Matlab-file iterator
interface, and it is currently not working.

Thanks,
- Brooks


-- 
Brooks Moses
CodeSourcery
brooks at codesourcery.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: matlab_bin_file.cpp
Type: text/x-c++src
Size: 9507 bytes
Desc: not available
URL: <http://sourcerytools.com/pipermail/vsipl++/attachments/20090724/3823ba56/attachment.cpp>


More information about the vsipl++ mailing list