Export excel file into matlab and make graph

Hello, I have 50+ Excel files in that i need to import in Matlab and convert into Graph.Do any one have idea how to do that automatically

2 Comments

Thanks for your reply
Is that possible to use some parameter from the file for example 2 parameters and plot them and save them in matlab as picture that is .fig file.
Like that it is possible for 50+ files
Hi, plot(Resultsforyyyy);figure(gcf); saveas(gcf,'Peile.fig') In the above line my pelie.fig is fixed one i want to use that with respect to the data i am plotting.Is that possible?

Sign in to comment.

 Accepted Answer

20 Comments

Thanks for your reply
Is that possible to use some parameter from the file for example 2 parameters and plot them and save them in matlab as picture that is .fig file.
Like that it is possible for 50+ files
Better go throgh the documentation of xlsread to see the variations it provides. And to save a matlab figure as picture:
h = plot(yourData(:,1),yourData(:));
saveas(h,'fileName','jpg');
Is it possible to make it loop and do this for more Excel files?
The link I gave you does exactly the same. You just need to make slight changes given you need to read excel sheets instead of image.
when i Run the code which you said to read i am getting the following Error. I am New to Matlab help me in sorting out this error
Error in qa (line 5) matData = load(matFilename);
That's just a prototype. Try to understand the code and make appropriate changes. I am sure you can do that on your own. And you should use xlsread instead of load .
Hello, saveas(h,'fileName','jpg'); In this once file name must be saved with respective to the image analyzed corresponding figure has to be generated.Is that possible?
generate the name using strcat inside the loop.
fileName = strcat('figure',num2str(ii));
saveas(h,fileName ,'jpg')
Hello, I tried using the solutions which is working for one image when try to execute in loop it is not working
myFolder = 'C:\Documents and Settings\yourUserName\My Documents';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.xls');
xlsFiles = dir(filePattern);
for k = 1:length(xlsFiles)
baseFileName = xlsFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
Array = xlsread(fullFileName);
h = plot(Array(;,1) , Array(:,2)); % plot.
drawnow; % Force display to update immediately.
figureFile = strcat('figure' , num2str(k) , '.jpg')
saveas(h , figureFile );
end
hello, when i run this code i get the following Error
Error in elsgm (line 14) h = plot(Array(:,1) , Array(:,2)); % plot.
That you have to figure out how data is arranged in the sheet.
Array = xlsread(fullFileName);
h = plot(Array); % Plots all the columns individually against the indices
Hello, I am interested in plotting two Parameters so i have added the following codes in the codes which you gave me.but i am getting the error.I have also attached the excel file which i need to generate Blob and Area in plot
Undefined variable "raw" or class "raw". | Error in Untitled4 (line 14) data = reshape([raw{:}],size(raw)); |
Array = xlsread(fullFileName,'Results','B3:C124'); data = reshape([raw{:}],size(raw)); Blob = data(:,1); Area = data(:,2); clearvars data raw; h=plot(Blob,Area);figure(gcf);% Plots all the columns individually against the indices drawnow; % Force display to update immediately. figureFile = strcat('figure' , num2str(k) , '.jpg') saveas(h , figureFile ); end
Hello, Thank you very much it really works!!
Hello, The solution which works fine.But Is that possible to save the image in the form which is being imported.but here it stored in the form of 'Figure'
figureFile = strcat('figure' , num2str(k) , '.jpg')
saveas(h , figureFile );
what do you mean by save the image in the form which is being imported?? what you did was import data from xls sheet and plot it.
Hello, Actually i am interested in saving the image file in the name which is being imported for example the excel file 1.sample1.xlsx 2.sample2.xlsx 3.sample3.xlsx if the excel file is in this format then plotted graph should be the same 1.sample1.jpg 2.sample2.jpg 3.sample3.jpg
figureFile = strcat(regexprep(baseFileName , '.xls' , '') , '.jpg')
saveas(h , figureFile );
% where baseFileName has already been evaluated in the loop earlier
Hello, Thank you very much it works.. I have attached a excel file in that there are 2 parameters in that first parameter is Number and second parameter is Area.In that Largest number of area must subtracted with rest of the whole area in the Excel.Is that possible
Hello, I have attached the file

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!