how to Read and process multiple rows from Excel
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
kmla
am 25 Sep. 2018
Bearbeitet: Adam Danz
am 25 Sep. 2018
I have 4 spreadsheets with about 20 rows. I'm trying to take the data from the same row in each spreadsheet and process it like so: A1 = xlsread(filename,'cluster','A1:AD1'); A2 = xlsread(filename,'Variance','A1:AD1'); ....... How can I make a loop that increases the row number each time it runs? I tried this code but it gives an error
for i=1:20
xlRange = 'A',i,':AD',i
A1 = xlsread(filename,'cluster', xlRange);
A2 = xlsread(filename,'Variance', xlRange);
end
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 25 Sep. 2018
Bearbeitet: Adam Danz
am 25 Sep. 2018
A loop solution (although I prefer the 2nd suggestion below). Here we define the range dynamically using sprintf().
Written on the fly; not tested...
nrows = 20;
for i = 1:nrows
xlrange = sprintf('A%d:I%d', i, i);
A1 = xlsread(filename,'cluster', xlrange )
A2 = xlsread(filename,'Variance', xlrange )
end
Instead, why not just read from all of the needed rows at the same time? Non-loop solution:
Written on the fly; not tested...
A1 = xlsread(filename,'cluster', 'A1:I5');
A2 = xlsread(filename,'Variance', 'A1:I5');
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!