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:
nest structure

Subject: nest structure

From: edward kabanyas

Date: 14 Apr, 2012 00:24:27

Message: 1 of 4

Dear all,

Before I have posted about saving structure to mat file (http://www.mathworks.com/matlabcentral/newsreader/view_thread/318994) and I have not yet found any solution. I tried as:

clear all;close all

%Making file list

fileList = getAllFiles( '*.txt');
[n, m] = size(fileList);
for jj=1:n
    
    %..data processing until I got an structure datpr (591 x 1 struct) for
    %the first file for example, then I save as:
    
    test= struct('time',[year month hour day],'nest',datpr);
    s(jj).test =test;
        
end

save('newstruct.mat', 's' 'append');

However, when I open s structure in the end of looping, test is empty. Could you show me how to nest the test, to get an accumulated test at the end of looping and then save all to a mat file. Thanks for help..

Edward

Subject: nest structure

From: edward kabanyas

Date: 14 Apr, 2012 07:26:33

Message: 2 of 4

Dear all,

Before I have posted about saving structure to mat file (http://www.mathworks.com/matlabcentral/newsreader/view_thread/318994) and I have not yet found any solution. I tried as:

clear all;close all

%Making file list

fileList = getAllFiles( '*.txt');
[n, m] = size(fileList);
for jj=1:n
    
    %..data processing until I got an structure datpr (591 x 1 struct) for
    %the first file for example, then I save as:
    
    test= struct('time',[year month hour day],'nest',datpr);
    s(jj).test =test;
        
end

save('newstruct.mat', 's' 'append');

However, when I open s structure in the end of looping, test is empty. Could you show me how to nest the test, to get an accumulated test at the end of looping and then save all to a mat file. Thanks for help..

Edward

"edward kabanyas" <djuky_hmi@yahoo.com> wrote in message <jmag3r$ivs$1@newscl01ah.mathworks.com>...
> Dear all,
>
> Before I have posted about saving structure to mat file (http://www.mathworks.com/matlabcentral/newsreader/view_thread/318994) and I have not yet found any solution. I tried as:
>
> clear all;close all
>
> %Making file list
>
> fileList = getAllFiles( '*.txt');
> [n, m] = size(fileList);
> for jj=1:n
>
> %..data processing until I got an structure datpr (591 x 1 struct) for
> %the first file for example, then I save as:
>
> test= struct('time',[year month hour day],'nest',datpr);
> s(jj).test =test;
>
> end
>
> save('newstruct.mat', 's' 'append');
>
> However, when I open s structure in the end of looping, test is empty. Could you show me how to nest the test, to get an accumulated test at the end of looping and then save all to a mat file. Thanks for help..
>
> Edward

Subject: nest structure

From: Bruno Luong

Date: 14 Apr, 2012 08:35:25

Message: 3 of 4

"edward kabanyas" <djuky_hmi@yahoo.com> wrote in message
> >
> > save('newstruct.mat', 's' 'append');
> >
> > However, when I open s structure in the end of looping, test is empty. Could you show me how to nest the test, to get an accumulated test at the end of looping and then save all to a mat file. Thanks for help..
> >

I'm not sure the correctness of the syntax in your save(...) command. Just save 's' without append (you won't append any thing here)

>> save('newstruct.mat', 's')

When load the file, you will get back the structure array 's', but not 'test'.

Bruno

Subject: nest structure

From: edward kabanyas

Date: 14 Apr, 2012 09:20:23

Message: 4 of 4

Dear Bruno,

Thanks for reply. Now it is working, the problem is at the input file in which the value is empty so that the s is always empty. Thanks again,

Edward




"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <jmbcsc$9hg$1@newscl01ah.mathworks.com>...
> "edward kabanyas" <djuky_hmi@yahoo.com> wrote in message
> > >
> > > save('newstruct.mat', 's' 'append');
> > >
> > > However, when I open s structure in the end of looping, test is empty. Could you show me how to nest the test, to get an accumulated test at the end of looping and then save all to a mat file. Thanks for help..
> > >
>
> I'm not sure the correctness of the syntax in your save(...) command. Just save 's' without append (you won't append any thing here)
>
> >> save('newstruct.mat', 's')
>
> When load the file, you will get back the structure array 's', but not 'test'.
>
> Bruno

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