Organize excel file from analysed data
15 views (last 30 days)
Show older comments
Good evening Gentleman and Ladies
I am a student working on dissertation and I am stuck with Matlab cause no one around is able to help.
My prof gave me a script which creates an output file with xlswrite. The output file is a single excel sheet with 40 columns and 100 rows, filled with numbers (data). This data sheet basically contains 10 repetitions.
What i would like matlab to do after xlswrite is to create 1 sheet every 4 columns. So 10 sheets as 1=abcd 2=efgh etc.
Also I would like to create 4 more sheets (named alpha beta gamma delta) in which for alpha every 1st column of the 10 created sheets is taken, or if you prefer column1, column5, etc (AEIM from the full sheet) and do the same for beta (BFJN) gamma (CGKO) and delta (DHLP). And so on.
I would also add peak, mean and st dev at the bottom of each sheet id possible.
Thanks for your help.
Romeo
0 Comments
Answers (1)
Bob Thompson
on 2 Aug 2016
If you have time, this would be actually easier to do in the ActiveX COM server, however, that can take a while to learn.
Using xlswrite, I would suggest creating a for loop that advances the sheet name each time.
% for loop for each sheet
for i = 1:10;
sheetname = sprint('Sheet%i',i);
% for loop for each column
for ii = 1:4;
xlswrite(fileout,data(:,ii+4*(i-1)),sheetname,range);
end
end
This should get you an idea of where to go, feel free to comment and I can add more later, but I don't have time to write a bunch more at the moment.
2 Comments
Bob Thompson
on 3 Aug 2016
Ha, I understand completely. We've all been at the point you're at. Do you understand what the code I wrote is doing? If not, I would suggest just googling the 'sprintf' command and for loops, since the MathWorks pages for them will give you a much more detailed description than anything I could write here.
If you do, then basically what you need to do next is duplicate that same set of for loops for your last four sheets (the AEIM ones). You will need to make sure you change the sheet name so that you don't overwrite your first four sheets, and you will need to change the advance method of your data calling. But otherwise they will look very similar.
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!