Reading several cell (not in range) from a Excel file
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
judy abbott
il 11 Lug 2016
Commentato: Image Analyst
il 11 Lug 2016
Dear all, I'm looking to read a serval cell not in range for example A1, A3 and A50 It work for a cell:
X1 = 1;
Val_X1 = ['A' num2str(X1) ':' 'A' num2str(X1)];
Y1 = xlsread('D:\file_1.xlsx',Val_X1)
Please how i make it work for a vector X1 =[1 3 50] ???
3 Commenti
Risposta accettata
Image Analyst
il 11 Lug 2016
Asuming you have a recent version of MATLAB, you can do this
Y1(1) = xlsread('D:\file_1.xlsx', 'A1')
Y1(2) = xlsread('D:\file_1.xlsx', 'A3')
Y1(3) = xlsread('D:\file_1.xlsx', 'A50')
If you have a version older than about R2015b, then if you have a lot of these, you should consider ActiveX. But with R2015b and later it shoudl be fast because MATLAB keeps Excel running in the background.
Alternatively, if you have a whole lot of x, then you could do it in a loop:
for k = 1 : length(x)
thisCell = sprintf('A%d', x(k));
Y1(k) = xlsread('D:\file_1.xlsx', thisCell);
end
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!