Loading in Multiple Excel Files using readmatrix
9 次查看(过去 30 天)
显示 更早的评论
Hi, I have this short code below but I am trying to import 5 excel files, names 101, 102, 103, 104 and 105.xlsx into matlab's workspace as separate cells so i can later make figures by calling on a column in each cell array.
They have the same number of columns (BS:BX) 6 columns is all I need but will have various rows. I'm new to MATLAB so maybe I am missing something easy here, it doesn't like the line "filename = (k,'%dtrf.xlsx');". "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters."
clear all
close all
mkdir myfolder
dir myfolder
for k = 101 : 105
filename = (k,'*.xlsx');
data = readmatrix(strcat(filename),'Range','BS:BX');
end
2 个评论
Mario Malic
2021-3-12
See this example https://matlab.fandom.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F and MATLAB Onramp, it's great way to dive in MATLAB.
回答(1 个)
Jan
2021-3-12
Folder = 'C:\Your\Folder';
for k = 101 : 105
filename = fullfile(Folder, sprintf('%d.xlsx', k));
data = readmatrix(filename, 'Range', 'BS:BX');
...
end
2 个评论
Souarv De
2023-5-31
@Natalie Klueppelberg Make sure whether the file you want to upload having .xlsx or .csv extension. You have to use the appropiate extension accordingly.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!