Borrar filtros
Borrar filtros

Reading several cell (not in range) from a Excel file

3 visualizaciones (últimos 30 días)
judy abbott
judy abbott el 11 de Jul. de 2016
Comentada: Image Analyst el 11 de Jul. de 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 comentarios
judy abbott
judy abbott el 11 de Jul. de 2016
Sorry, i want to say :several, lot, serie or a vector of cell
Image Analyst
Image Analyst el 11 de Jul. de 2016
But what about my Answer below???

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 11 de Jul. de 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

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by