Looping Excel files in one varibale

1 次查看(过去 30 天)
So, I want to take input of few excel files, I could have hardcoded it by assigned different varibales to each excel file, but I want to iterate this process so that it can be used for larger set of files. I tired one similar code but it shows this error. Can someone help me with this?
code:
for i = 1:4
baseFileName = 'LD-1';
extension = num2str(i);
filename = strcat(baseFileName,extension,'xlsx');
LDT(i) = [xlsread('Excel Data/LD-1-1.xlsx','C2:BL14')];
LDT(i) = sum(LDT(i));
end
file names are LD-1-1, LD-1-2, LD-1-3 and so on

回答(1 个)

VBBV
VBBV 2023-6-1
LDT{i} = 
LDT{i} = 
  2 个评论
VBBV
VBBV 2023-6-1
编辑:VBBV 2023-6-1

Use cell array to store matrix since C2:BL14 is range of matrix with more than one row and column and you try to fit them in one element. It's better to use readmatrix instead of xlsread as recommended by Matlab

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by