Re: export mathematica table to .mat (MATLAB) format.Please help!!!
- To: mathgroup at smc.vnet.net
- Subject: [mg88771] Re: export mathematica table to .mat (MATLAB) format.Please help!!!
- From: Albert Retey <awnl at arcor.net>
- Date: Fri, 16 May 2008 05:31:31 -0400 (EDT)
- References: <g0h4k2$l9p$1@smc.vnet.net>
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: Export[ 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: Export[ ToFileName[{$HomeDirectory, "Desktop"}, "tst.mat"], { "var1" -> {{0.272409}}, "var2" -> {{0.132711 + 0.231672 \[ImaginaryI], 0.221351, -0.130221 + 0.226132 \[ImaginaryI]}} }, "Rules" ] (I have not checked the result, just took care that Export will succeed...) hth, albert