help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cell array of matrices -> N-d array?


From: Jordi Gutiérrez Hermoso
Subject: Re: cell array of matrices -> N-d array?
Date: Wed, 9 May 2012 13:47:34 -0400

On 9 May 2012 13:30, Dan Muresan <address@hidden> wrote:
>>> NxN cell array of 3x3 matrices
>>>
>>> to an
>>>
>>> NxNx3x3
>>>
>>> N-dimensional array?
>>
>> Try,
>>
>>    resize(cell2mat(c), [n,n,3,3])
>
> Hi Jordi, that makes result (1, 1, :, :) non-zero, and the rest of it zero.
>
> Did you mean reshape?

Yes.

> I tried reshape with both [n, n, 3, 3] and [3,
> 3, n, n] and it doesn't seem to preserve the correct order of the
> elements.

This is just off the top of my head, so forgive me if this is ugly:

   permute(reshape(vertcat(cellfun(@(x) x(:), c, "unif", false){:}),
3, 3, n, n), [3,4,1,2])

- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]