フィルターのクリア

Read and process multiple sheets from Excel to Matlab

2 ビュー (過去 30 日間)
Francesca Danielli
Francesca Danielli 2021 年 12 月 21 日
編集済み: Stephen23 2021 年 12 月 21 日
Hi!
I have an Excel file with N sheets.
Each sheet contains two coloumns (x and y coordinates of a curve).
I want to read them in Matlab at once, save data and plot them.
Any suggestion?
Thank you
  2 件のコメント
Mitchell Thurston
Mitchell Thurston 2021 年 12 月 21 日
the second argument in xlsread is the sheet number, https://www.mathworks.com/help/matlab/ref/xlsread.html#bthgbma
you can either iterate through the sheet numbers in a loop, or just define the sheets you want to read. As far as I know, there isn't an automatically "read all of the sheets". hope this helps
Stephen23
Stephen23 2021 年 12 月 21 日
編集済み: Stephen23 2021 年 12 月 21 日
Avoid using deprecated and discouraged XLSREAD.
For your task you should probably use READTABLE or READMATRIX.
Because you did not upload any sample files you make it much harder for people to write code for you and help you.

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2021 年 12 月 21 日
編集済み: Stephen23 2021 年 12 月 21 日
Untested, but this should get you started:
P = 'absolute or relative path to where the files are saved';
F = 'filename.xlsx';
S = sheetnames(fullfile(P,F));
N = numel(S);
C = cell(1,N);
for k = 1:N
C{k} = readtable(fullfile(P,F), 'Sheet',S(k));
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by