How to create a loop that will plot multiple excel files into seperate graphs
15 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I'm trying to plot a bunch of individuals graphs using individual excel sheets. I want to extract the same variables ( all of them are organized in the same way).
For this, I know I have to create a loop and add my plotting function within it but I am having a bit of trouble doing this.
I have a looping code here, but I'm not sure how to integrate the plotting function I need into.
My file names increment from 101trf.xlsx, 102trf.xlsx, 103trf.xlsx and so forth.
Here's the code I have for the loop:
myFolder= dir('D:\Thesis\Reports\Encoding\Encoding Trial Reports\Free viewing Reports\Run1');
filePattern = fullfile(myFolder, '.xlsx'); % Change to whatever pattern you need.
theFiles = dir('101trf','102trf','103trf','104trf','105trf','106trf','107trf','108trf','109trf','110trf','111trf','112trf','113trf');
for k = 1 : length(theFiles)
baseFileName = theFiles(k).xlsx;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
end
I want to extract the colomns with the name 'trialnum' and 'FIXATION_COUNT' within these files to create a bar plot for them.
Thanks in advance!
0 件のコメント
回答 (1 件)
darova
2019 年 9 月 24 日
Try this. Don't forget to change column range!
myFolder = 'D:\Thesis\Reports\Encoding\Encoding Trial Reports\Free viewing Reports\Run1';
filePattern = fullfile(myFolder, '.xlsx'); % Change to whatever pattern you need.
for k = 101 : 113
fullFileName = [myFOlder sprintf('%dtrf.xlsx',k)];
colA = xlsread(fullFileName,'A:A'); % what is you column?
colB = xlsread(fullFileName,'B:B');
figure
bar(colA,colB)
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!