필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
judy abbott
judy abbott 2016년 7월 11일
댓글: Image Analyst 2016년 7월 11일
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
judy abbott
judy abbott 2016년 7월 11일
Sorry, i want to say :several, lot, serie or a vector of cell
Image Analyst
Image Analyst 2016년 7월 11일
But what about my Answer below???

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2016년 7월 11일
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개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by