Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Structures within For Loops
Replies: 16   Last Post: Jun 9, 2013 10:54 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Mary

Posts: 20
Registered: 12/7/10
Structures within For Loops
Posted: Jun 5, 2013 12:59 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello!

I'm working on populating .mat files with structs which are filled with data from xls spreadsheets.

In the spreadsheets data is listed in groups of 10, such that 10 rows correspond to one .mat I need to build.

function filter_example.m
files = dir('*.xls')
a=2
c=2
d=1
b=1
for i= 1:numel(files)

filename = files(i).name
[data,textdata,raw]=xlsread(filename)

for j = 1:numel(textdata) % for 1 through the # of rows in the sheet

for k = 1:10 % for the set of 10 it's pulling from
R=round(b); % I want this to change R every time it loops
R.block= data(a,1);
.
.
.

a=a+1;
d=d+1;
b=b+1;
end

name=textdata(c,1); % takes group name and saves the .mat as that group name
savefile=char(name);

save (savefile)
a=a+10;
d=d+10;
c=c+10;

end
end
end


When I run this code, it works for R(1), but it does not populate any data for R(2) or R(3) - it just overwrites itself 10 times.

How do I go about fixing this?

Thanks,

Mary




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.