[R] Saving a 3d array into a matlab file

Henrik Bengtsson hb at stat.berkeley.edu
Sat Nov 1 21:17:23 CET 2008

Hi,  a follow up on this: I've fixed the below bug in writeMat().
R.matlab v1.2.4 is now available on CRAN.  Please update.


On Tue, Oct 28, 2008 at 3:30 PM, Henrik Bengtsson <hb at stat.berkeley.edu> wrote:
> Hi,
> On Tue, Oct 28, 2008 at 2:25 PM, Minho Chae <minho.chae at gmail.com> wrote:
>> Dear R users,
>> I am tryting to save an 3d array to a matlab file like the following.
>> A <- array(1:24, c(2,3,4))
>> writeMat(filename, A=A)
>> But if I load the mat file from Matlab, it is not 3d matrix anymore.
>> Does anyone know how I can preserve the 3d structure?
>> Any help will be greatly appreciated.
> This is a bug that I'll have to look into.  The dimension seems to get
> lost.  I'll also have to fix an earlier problem with writeMat()
> existing in R.matlab v1.2.2 and later.  See archive how to install the
> latest stable version v1.2.1.  In the meanwhile you can do something
> like:
> writeMat(filename, list(A=A, dim=dim(A)))
> and reassign the dimension manually in Matlab (I don't know how that's
> done though).
> FYI, readMat() is way more stable/tested than writeMat().  The only
> redundancy tests I can do on writeMat() is to try to read the data
> back in using readMat().  I have little time to load writeMat()
> written *.MAT files in Matlab.
> /Henrik
>> Minho Chae
>>        [[alternative HTML version deleted]]
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list