MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: importing mat format doesn't import variable names

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53610] Re: importing mat format doesn't import variable names
  • From: schaferk <schaferk at bellsouth.net>
  • Date: Thu, 20 Jan 2005 03:47:51 -0500 (EST)
  • References: <200501130812.DAA03781@smc.vnet.net> <cs8kid$ejl$1@smc.vnet.net> <csaeg8$ose$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

greetings:
i can confirm that it looks like you can only Export one array at the 
time. also note that Mathematica creates it/s own names for the arrays like
ExpressionX  where X \in {1,2,3,4,...}.

now what/s fun is when you go to that 'other' program that these "MAT" 
arrays are created for and start loading them.

Mathematica>

s = data[[indexdata]][[1, 1]]

{2000090116, 38.51, -73.12, 24}

Export["bob.mat", s]

bob.mat

!! bob.mat

è
Expression11AÝͽ@CAG®záÀRG®záH@8

Note the unprintable characters and the name ('Expression11')

now from the 'other' program:


 >> s=load('bob.mat')

s =

     Expression11: [4x1 double]

 >> Expression11
??? Undefined function or variable 'Expression11'.

at least you know the name, now:


 >> load('bob.mat')
 >> Expression11

Expression11 =

    1.0e+09 *

     2.0001
     0.0000
    -0.0000
     0.0000

what happened to the values?

dumping mixed values seems problematic.

how about dumping all reals?

back to Mathematica

s=data[[indexdata]][[1,2]]

{{0., 24.73, 34.09}, {5., 24.49, 34.09}, {
   10., 23.93, 34.21}, {15., 23.03, 34.42}, {20., 20.49, 34.58}, {
     30., 16.65, 34.81}, {50., 15.2, 35.26}, {75.,
      14.68, 35.58}, {100., 14.24, 35.7}, {125., 13.7, 35.7}, {
   150., 12.24, 35.57}, {200., 10.74, 35.42}, {250., 9.53, 35.31}, {
     300., 7.43, 35.16}, {400., 6.16, 35.08}, {
     500., 5.44, 35.04}, {600., 4.96, 35.02}, {700., 4.64, 35.}, {800., 
4.41,
     34.99}, {900., 4.26, 34.99}, {1000., 4.13, 34.98}, {
     1100., 4.02, 34.98}, {1200., 3.91, 34.98}, {1300., 3.83, 34.98}}

back to the 'other' program.

 >>  load('bob.mat')
 >> s=load('bob.mat')

s =

     Expression15: [24x3 double]

 >> Expression15

Expression15 =

    1.0e+03 *

          0    0.0247    0.0341
     0.0050    0.0245    0.0341
     0.0100    0.0239    0.0342
     0.0150    0.0230    0.0344
     0.0200    0.0205    0.0346
     0.0300    0.0166    0.0348
     0.0500    0.0152    0.0353
     0.0750    0.0147    0.0356
     0.1000    0.0142    0.0357
     0.1250    0.0137    0.0357
     0.1500    0.0122    0.0356
     0.2000    0.0107    0.0354
     0.2500    0.0095    0.0353
     0.3000    0.0074    0.0352
     0.4000    0.0062    0.0351
     0.5000    0.0054    0.0350
     0.6000    0.0050    0.0350
     0.7000    0.0046    0.0350
     0.8000    0.0044    0.0350
     0.9000    0.0043    0.0350
     1.0000    0.0041    0.0350
     1.1000    0.0040    0.0350
     1.2000    0.0039    0.0350
     1.3000    0.0038    0.0350

is this facility ready for 'real' work?

m. r.

Ben Barrowes wrote:
> It seems that Import extracts only numerical data and loses the variable 
> names from MAT files.
> 
> OK, how about an Export problem?
> 
> Let's say I have two arrays:
> aa={2,3}
> and
> bb={{9,8,7},{6,5,4},{3,2,1}}
> 
> How can I save both of these to a MAT file?
> 
> I can save either one, e.g.:
> Export["filename",aa,"MAT"];
> 
> But if I try to:
> Export["filename",{aa,bb},"MAT"];
> 
> The resulting file size is 0 and the Import consequently fails.
> 
> Any way to export more than one matrix to a MAT file?
> 
> 
> What I would really like to do is save all the currently defined 
> variables to a MAT file. I tried:
> 
> Export["filename",ToExpression[Names["`*"]],"MAT"];
> 
> But that fails in the same way as the preceeding example when there is 
> more than one variable defined.
> 
> 
> 
> Tomas Garza wrote:
> 
>>Could you give us a small example of the file you're trying to import 
>>(perhaps 3 x 3), including the variable names?
>>
>>Tomas Garza
>>Mexico City
>>----- Original Message ----- 
>>From: "Ben Barrowes" <barrowes at alum.mit.edu>
To: mathgroup at smc.vnet.net
>>Subject: [mg53610]  importing mat format doesn't import variable names
>>
>>
>>
>>
>>>This is a very responsive ng. Thanks!
>>>
>>>When I Import["file","MAT"] files, the variable name information is
>>>lost. Is this the normal behavior? Or is there a switch I can specify to
>>>import the variable names as well?
>>>
>>>For example, if file.mat has two variables, foo (3x3) and bar (3x3), and
>>>I Import it, all I get is 1 nested List for a result.
>>>{{{foo[[1,1]],foo[[1,2]],foo[[1,3]]},...},{{bar[[1,1]],...}}}
>>>However, they are simply numbers with no names associated with the list.
>>>
>>>I know I could do:
>>>{foo,bar}=Import["file.mat","MAT"];
>>>
>>>but I was wondering if there was a way to Import variable names without
>>>specifying them explicitly. The information is in the .mat file. Why
>>>doesn't Mathematica extract it?
>>>
>>>Similarly, when I Export a matrix into a mat file, will the variable
>>>name be lost?
>>>
>>>Ben Barrowes
>>>
>>>
>>
>>
>>
> 


  • Prev by Date: Re: init.m problem, WinXP with 5.0.1.0
  • Next by Date: Re: Mathematica Graphics output in an ASP.NET WebApplication
  • Previous by thread: Re: Re: importing mat format doesn't import variable names
  • Next by thread: cubic quarternion group