MathGroup Archive 2008

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

Search the Archive

Re: export mathematica table to .mat (MATLAB) format.Please help!!!

Alex wrote:
> Hi,
> I am aware of this. I simply changed it to make the text more readable. This is because I copy pasted the values directly from the table in this box.
> The first few entries is simply an example of the Table as I see it. I have also used the command MatrixForm[%].
> Now when I try to export this it fails. HELP PLEASE!!!!!!!! 
> So a different sample of what I see follows:
> {
>  {{0.272409}},
>  {{0.132711+ 0.231672 \[ImaginaryI], 
>    0.221351, -0.130221 + 0.226132 \[ImaginaryI]}}
> }
> I then use MatrixForm[%]
> I then use Export["file.mat", Out[6]] and it fails.WHY???

Unfortunatly the documentation of many export formats is, well
rudimentary. This is from the documentation:

Export["file.mat",expr] exports any numeric array to a MAT-file.

I think this tries to tell you that only full arrays (of dimension 1 or
2?) can be exported this way. So you need to massage your data to export:

You can pad the data (look at PadRight) and make it a matrix:

 ToFileName[{$HomeDirectory, "Desktop"}, "tst.mat"], {{
   {0.272409, 0, 0},
   {0.132711 + 0.231672 \[ImaginaryI],
    0.221351, -0.130221 + 0.226132 \[ImaginaryI]}

Another possibility is to export more than one matrix to one file, but
then you need to use names for the variables:

 ToFileName[{$HomeDirectory, "Desktop"}, "tst.mat"], {
  "var1" -> {{0.272409}},
  "var2" -> {{0.132711 + 0.231672 \[ImaginaryI],
    0.221351, -0.130221 + 0.226132 \[ImaginaryI]}}

(I have not checked the result, just took care that Export will succeed...)



  • Prev by Date: Re: Asking NonlinearRegression
  • Next by Date: Re: cell convert to
  • Previous by thread: Re: export mathematica table to .mat (MATLAB) format.Please help!!!
  • Next by thread: Re: export mathematica table to .mat (MATLAB) format.Please help!!!