I have multiple excel files (~100) in a folder. Each time I have to process it to plot graph in matlab. Is there any coding to process all graph and plot it?
You can use the xlsread command to open data from an excel file. I have attached a basic example of how you might use it to generate plots from all the excel files in a directory. Save the .m file to the directory you want to process, hit 'F5' to run it, and then approve the change in directory, and it should generate a plot for every .xlsx file in the folder. It can be easily modified to work for .xls files as well, notes are given in the file. The data can easily be processed once it is loaded, just insert processing commands before the plotting statement.
You can use the xlsread command to open data from an excel file. I have attached a basic example of how you might use it to generate plots from all the excel files in a directory. Save the .m file to the directory you want to process, hit 'F5' to run it, and then approve the change in directory, and it should generate a plot for every .xlsx file in the folder. It can be easily modified to work for .xls files as well, notes are given in the file. The data can easily be processed once it is loaded, just insert processing commands before the plotting statement.
I think Shannon already showed a good solution. Maybe you can get your code more flexible by using a string variable called BasePath (like 'C:\program files\Matlab\data') and add the string '\*.xlsx' either before or inside of the dir function call. Then use the dir command like dir([BasePath,'\*.xlsx']). By doing so you can remove the strcmpi(filename(end-4:end), '.xlsx') call inside of the loop and improve the speed of your code. Of course your for loop has to start with 1 now. You do not have to change your current work directory with this little changes. This might be a benifit.
Additionally, you can take advantage of the naming of your .xls files and import via xlsread in a loop. Be aware that multiple xlsread commands can be very, very slow. You might want to add some print statements during your read process so you know that something is actually happening.
Nice answer Shannon Nicley. May I have some question since I'm newbie in matlab?:
(1) But, what if we want to plot of x,y of all files in one figure instead of plot it in separate files?
(2) If I have done some processes in each xlsx files and then I have got the value(s) derived from such operation; after that I want to plot such derived value(s); what kind of script I should insert in the operation script to plot those values (either to plot it in separate fig file or combine it within a figure)