ploting Multiple graphs from multiple excel sheets using Matlab 2018
23 次查看(过去 30 天)
显示 更早的评论
[status,sheets,xlFormat]=xlsfinfo('Majorfaults_300m_10profiles.xlsx')
A=cell2mat(sheets)
for idx_cell = 1:size(sheets,1) out.(sheets{idx_cell})={}; end
A = cell2mat(sheets(1))
A= convertCharsToStrings(cell2mat(sheets(1)))
This is what I have tried so far, but my sheets are not being converted into matrices! I need to do that and then from each sheet plot a graph with column A vs. Column B E F D ..
and repeat for all sheets I have.
At the end I need 68 Figures from 68 sheets.
Thank you!
0 个评论
回答(1 个)
Walter Roberson
2021-8-26
filename = 'Majorfaults_300m_10profiles.xlsx';
[status, sheets] = xlsfinfo(filename);
if isempty(status); error('Cannot find sheets in file "%s"', filename); end
out = struct();
for idx_cell = 1:size(sheets,1)
thissheet = sheets{idx_cell};
thisdata = readmatrix(filename, 'sheet', thissheet);
out.(thissheet) = thisdata;
fig = figure();
ax = axes(fig);
plot(ax, thisdata(:,1), thisdata(:,[2 5 6 4]));
legend(ax, {'B', 'E', 'F', 'D'});
xlabel(ax, 'A');
title(ax, thissheet);
end
This code reads and plots, and also stores the data in the struct out .
One figure is created for each sheet.
... That's a lot of figures. Wouldn't you prefer to write the result as images or something like that? Maybe a movie?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!