How to select a submatrix from a bigger one?

4 ビュー (過去 30 日間)
Igor
Igor 2015 年 8 月 3 日
回答済み: Image Analyst 2015 年 8 月 3 日
So, I've got an Excel file that contains a matrix that's over 50 columns wide, and a Matlab script that uses xlsread to extract that matrix and do some computations on it.
But, the user of the script might not want to use the whole matrix, he might only want 15 columns from it, for example.
Now I'd need to write a code that would allow a user to select which columns he'd like to use in his computations. Anyone have an idea for an elegant / convenient / user friendly solution?

採用された回答

Image Analyst
Image Analyst 2015 年 8 月 3 日
The best way would be to use ActiveX (if you're on Windows) and launch the file, then put up a message box telling the user to go to Excel and select columns. Then come back to the message box and click OK and then use ActiveX methods to extract only those columns that the user highlighted. I don't have any code that does exactly that but I can attach a demo of how you can open a workbook with ActiveX and do some things, like read from it. You just need to find the right ActiveX command to read the selected range. To find out what the method is, record a macro in Excel (this is easiest) or see the documentation https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range_methods.aspx

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 8 月 3 日
編集済み: Azzi Abdelmalek 2015 年 8 月 3 日
idx=input('choose your 15 columns')
M=A(:,idx)

カテゴリ

Help Center および File ExchangeActiveX についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by