I need to take the data of more than 100 excel files. I have managed to obtain the name of each one of the files but when I use readmatrix it gives me an error.

1 回表示 (過去 30 日間)
Matlab
Matlab 2022 年 11 月 26 日
コメント済み: Matlab 2022 年 11 月 26 日
clear all;
clear; %With these code I can create the names of all the files who have a
clc; %similar name to the file I posted. But when i try to use readmatrix
stations= ["C042","C057","C061","C067"]; %using the variable filename, it says that filename doesn't exist.
parameters=["AirTemp","Precipitation","WindSpeed"]; %I would appreciate your help.
for station=stations %Thanks
for parameter=parameters
for month=01:12
filename=sprintf("%s_%s_2021%02d.csv",station,parameter,month)
data= readmatrix("PROJECT\PROJECTDATA\'filename'")
end
end
end
  2 件のコメント
Stephen23
Stephen23 2022 年 11 月 26 日
編集済み: Stephen23 2022 年 11 月 26 日
ffnm = fullfile("PROJECT\PROJECTDATA",filename);
data = readmatrix(ffnm);

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

回答 (1 件)

Frantisek Gaspar
Frantisek Gaspar 2022 年 11 月 26 日
For reading tabular data I recomend readtable function. The function can be set to handle various files and is quite robust. If there are multiple files I alos recoment datastore function which can make the loading more convenient,

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by