Thread Subject: 3D array to struct?

Subject: 3D array to struct?

From: Volker Klink

Date: 4 Nov, 2009 10:24:02

Message: 1 of 3

Hi! This is probably very simple but I#M stuck with it.

I would like to transform a m-by-n-by-x array into a struct.

Length of the struct is supposed to be x and the field 'cdata' is supposed to contain the m-by-n matrices.

--> I want to convert a 3D image array into the required movie structure.

Any ideas?

Thanks
Volker

Subject: 3D array to struct?

From: Bruno Luong

Date: 4 Nov, 2009 11:29:02

Message: 2 of 3

% Your matrix
A=rand(2,2,3)

s=struct('cdata',squeeze(num2cell(A,[1 2])))

% Bruno

Subject: 3D array to struct?

From: Volker Klink

Date: 4 Nov, 2009 11:54:01

Message: 3 of 3

Awesome! Works perfectly! Thanks for that quick solution! (I love this newsgroup!)

> A=rand(2,2,3)
> s=struct('cdata',squeeze(num2cell(A,[1 2])))
> % Bruno

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
struct array Volker Klink 4 Nov, 2009 05:29:03
rssFeed for this Thread

Contact us at files@mathworks.com