extract values from specific cells in excel

50 ビュー (過去 30 日間)
olu
olu 2013 年 8 月 1 日
編集済み: Carlos GU 2022 年 7 月 30 日
Hi, I would like to values from specific cells in excel file>>>>>>. Please help me with script to do that. for example, I would like to copy values from cells A1, A6, A11,..A1501....and cells B1, B6, B11,.....B1501 ( as shown in the attached file) into another excel file format. Please note that the reoccurence could be more than the 5 cells in this example. That is it could be A1, A11, A21 (10 cells jump)...or A1, A33, A65,..(32 cells jump) etc. but in all cases reoccurence is always constant.
Thanks for helping

採用された回答

Caroline
Caroline 2013 年 8 月 1 日
You can use xlsread:
For example: num = xlsread(filename,sheet,xlRange) and you can specify xlRange to be whatever columns you want to read and it will save all of the values in the cell array num. Then you could possibly index into that cell array and get the values that you need and save those values in a new array.
The you can use xlswrite:
xlswrite(filename,A,sheet,xlRange)
where A would be the array that you created
  4 件のコメント
olu
olu 2013 年 8 月 1 日
Hi Caroline, thanks so much for this. It has helped me solve my problem. You are a life saver.
cheers
C G
C G 2018 年 4 月 5 日
How do I combine the values from columns A and B? For example, I would like a new variable with the values from A1 and B1 in the same variable? Then have a new variable containing the values of A2 and B2 in the new variable... and so on.

サインインしてコメントする。

その他の回答 (1 件)

Prakash Adhikari
Prakash Adhikari 2020 年 9 月 15 日
編集済み: Prakash Adhikari 2020 年 9 月 15 日
How do I find the row and column number of a specific data of excel file in matlab?
  1 件のコメント
Carlos GU
Carlos GU 2022 年 7 月 30 日
編集済み: Carlos GU 2022 年 7 月 30 日
Hi
you can xlsread the file and then use 'find' to get row and column number as below script:
File=xlsread(filename);
[rowlist, collist]=find(File=='specific data');
If you want to get the column letters instead of column number, below link may help you:

サインインしてコメントする。

カテゴリ

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