Looping Excel files in one varibale

1 view (last 30 days)
Siddharth Sankhe
Siddharth Sankhe on 1 Jun 2023
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

Answers (1)

VBBV
VBBV on 1 Jun 2023
LDT{i} = 
LDT{i} = 
  2 Comments
VBBV
VBBV on 1 Jun 2023
Edited: VBBV on 1 Jun 2023

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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!