Need to create multiple graphs from different sheets in Excel !!

17 views (last 30 days)
Hello I am new to Matlab therefore the most basic stuff might need explaining. I have an excel file of roughly 120 worksheets. In each worksheet i have two columns (2I:97I, 2J:97J) that I have have to plot in a scatter formation. So in the end I need 120 graphs (if you want to add in code to make them look nice and fit together that would be cool too) I can label the axis manually but I need to label the title with the tile of each worksheet. The data of the work sheets start on page 3.
That's my first issue but if there is an easy way to put in a code that could loop multiple excel files together please let me know!
Any help is much appreciated.
  2 Comments
Image Analyst
Image Analyst on 25 May 2015
This is very confusing. What is "page 3"? Where do you need these 120 graphs - in MATLAB or in the Excel workbook? What do you mean by "loop multiple excel files" - I though you had just one Excel workbook file with 120 sheets in it. Do you have more than one workbook? And if so, what does "loop them together" mean???
Andrea Slane
Andrea Slane on 26 May 2015
Sorry here is what I have so far :
>> filename= 'A1.xls';
>> sheet= 1;
>> x=xlsread(filename,3,'I2:I97');
>> y=xlsread(filename,3,'J2:J97');
>> figure
>> scatter(x,y,'filled')
This is what I have started just to create one graph. By page I meant Sheet 3. The graphs would be best in Excel but either way is fine. I do have more than one Workbook (around 90) but if I could get this to work for just a few that would be a great start.
thank you

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 26 May 2015
To process multiple Excel workbook files, see the code snippets in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
For so many workbooks, with tons of sheets in each workbook, if you don't want it to take forever, I really recommend you use ActiveX (if you're using Windows). I've attached a demo of that. You can use ActiveX to create graphs in Excel, though it might be easier if you just pre-created them in Excel and saved the workbook in advance, then filled in the appropriate columns by MATLAB, so then Excel will plot them automatically. Or if the data is of variable length, then you could create a macro in Excel, then use ActiveX to fire off the macro which will then define the data ranges and create the graphs.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!