Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
4D matrix processing

Subject: 4D matrix processing

From: Zort

Date: 29 Mar, 2011 18:15:23

Message: 1 of 4

Hello,
I'm having trouble with this.
I have 10 different .mat files, each contains a 4D matrix size = 2 71 76 200.
I need to:
1.- split each matrix according to the first dimension (i.e. each .mat file gives two matrices size = 1 71 76 200) per each .mat file.
2.- create a new 4D matrix containing one of the splits from each one of the 10 .mat original files (i.e. first split 4D matrix size = 1 71 76 200 from file 1.mat, with the first split 4D matrix size = 1 71 76 200 from file 2.mat, and so on... into a new 4D matrix size = 10 71 76 200).

Older posts on 4D matrices refer to this link http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f1-86528.html
which is the documentation on 4D matrices, and is not working.
I'd really appreciate your help.
Thanks!

Subject: 4D matrix processing

From: Florin Neacsu

Date: 29 Mar, 2011 18:37:05

Message: 2 of 4

"Zort" wrote in message <imt7jr$rpl$1@fred.mathworks.com>...
> Hello,
> I'm having trouble with this.
> I have 10 different .mat files, each contains a 4D matrix size = 2 71 76 200.
> I need to:
> 1.- split each matrix according to the first dimension (i.e. each .mat file gives two matrices size = 1 71 76 200) per each .mat file.
> 2.- create a new 4D matrix containing one of the splits from each one of the 10 .mat original files (i.e. first split 4D matrix size = 1 71 76 200 from file 1.mat, with the first split 4D matrix size = 1 71 76 200 from file 2.mat, and so on... into a new 4D matrix size = 10 71 76 200).
>
> Older posts on 4D matrices refer to this link http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f1-86528.html
> which is the documentation on 4D matrices, and is not working.
> I'd really appreciate your help.
> Thanks!

Hi,

"> I'm having trouble with this. "

What kind of trouble ? what did you try and did not work ?

Can you provide some code and error you get ? (Because this seems like basic matrix manipulation to me, if I'm not overlooking some aspects).

Florin

Subject: 4D matrix processing

From: Matt J

Date: 29 Mar, 2011 18:42:04

Message: 3 of 4

"Zort" wrote in message <imt7jr$rpl$1@fred.mathworks.com>...
> Hello,
> I'm having trouble with this.
> I have 10 different .mat files, each contains a 4D matrix size = 2 71 76 200.
> I need to:
> 1.- split each matrix according to the first dimension (i.e. each .mat file gives two matrices size = 1 71 76 200) per each .mat file.
> 2.- create a new 4D matrix containing one of the splits from each one of the 10 .mat original files (i.e. first split 4D matrix size = 1 71 76 200 from file 1.mat, with the first split 4D matrix size = 1 71 76 200 from file 2.mat, and so on... into a new 4D matrix size = 10 71 76 200).
====================

Here is one method. I restrict myself to 3 files for the purposes of the example:


%Data
A=rand([2 71 76 200]); save File1 A
A=rand([2 71 76 200]); save File2 A
A=rand([2 71 76 200]); save File3 A



%%Engine
Files={'File1', 'File2', 'File3'};
 numFiles=length(Files);
 
Data=cell(1,numFiles);

Data5D=zeros(numFiles,2,71,76,200);

for ii=1:numFiles
    
    S=load(Files{ii});
    Data5D(ii,:,:,:,:)=S.A;
    
end

Split1=squeeze(Data5D(:,1,:,:,:));
Split2=squeeze(Data5D(:,2,:,:,:));



%%Check

>>Whos Split1 Split2

  Name Size Kilobytes Class Attributes
                                                            
  Split1 3x71x76x200 25293.75 double
  Split2 3x71x76x200 25293.75 double
                                                       

Subject: 4D matrix processing

From: Zort

Date: 30 Mar, 2011 14:22:04

Message: 4 of 4

Thank you so much! I'll try this method. But apparently is going to work!

Thanks again!

"Matt J" wrote in message <imt95s$pq5$1@fred.mathworks.com>...
> "Zort" wrote in message <imt7jr$rpl$1@fred.mathworks.com>...
> > Hello,
> > I'm having trouble with this.
> > I have 10 different .mat files, each contains a 4D matrix size = 2 71 76 200.
> > I need to:
> > 1.- split each matrix according to the first dimension (i.e. each .mat file gives two matrices size = 1 71 76 200) per each .mat file.
> > 2.- create a new 4D matrix containing one of the splits from each one of the 10 .mat original files (i.e. first split 4D matrix size = 1 71 76 200 from file 1.mat, with the first split 4D matrix size = 1 71 76 200 from file 2.mat, and so on... into a new 4D matrix size = 10 71 76 200).
> ====================
>
> Here is one method. I restrict myself to 3 files for the purposes of the example:
>
>
> %Data
> A=rand([2 71 76 200]); save File1 A
> A=rand([2 71 76 200]); save File2 A
> A=rand([2 71 76 200]); save File3 A
>
>
>
> %%Engine
> Files={'File1', 'File2', 'File3'};
> numFiles=length(Files);
>
> Data=cell(1,numFiles);
>
> Data5D=zeros(numFiles,2,71,76,200);
>
> for ii=1:numFiles
>
> S=load(Files{ii});
> Data5D(ii,:,:,:,:)=S.A;
>
> end
>
> Split1=squeeze(Data5D(:,1,:,:,:));
> Split2=squeeze(Data5D(:,2,:,:,:));
>
>
>
> %%Check
>
> >>Whos Split1 Split2
>
> Name Size Kilobytes Class Attributes
>
> Split1 3x71x76x200 25293.75 double
> Split2 3x71x76x200 25293.75 double
>

Tags for this Thread

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.

Contact us