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 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Frantisek Gaspar
on 26 Nov 2022
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,
0 Comments
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!