フィルターのクリア

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 Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by