Looping Excel files in one varibale

1 visualizzazione (ultimi 30 giorni)
Siddharth Sankhe
Siddharth Sankhe il 1 Giu 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

Risposte (1)

VBBV
VBBV il 1 Giu 2023
LDT{i} = 
LDT{i} = 
  2 Commenti
VBBV
VBBV il 1 Giu 2023
Modificato: VBBV il 1 Giu 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

Siddharth Sankhe
Siddharth Sankhe il 1 Giu 2023
This worked! Thanks

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by