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?
2 件のコメント
Walter Roberson
2021 年 8 月 26 日
sheets = sheetnames(filename);
and remove the isempty(status) test.
参考
カテゴリ
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!