Compare text to a column value and write corresponding row to new file

1 回表示 (過去 30 日間)
Joseph Corry
Joseph Corry 2021 年 3 月 15 日
コメント済み: ANKUR KUMAR 2021 年 3 月 16 日
I need to write a code that will read every value in a matrix colum (about 5,000 entries long), compare the value in each cell to an existing variable and if the cell value matches the existing variable, write the entire row to a new table.
I am thinking I will need to use a 'for' loop to evaluate the entire matrix and string compare but I am not sure how to go about writing this.

採用された回答

ANKUR KUMAR
ANKUR KUMAR 2021 年 3 月 15 日
You can find the indices of matching values in matrix and cell.
matrix=randi(10,1,100);
cell_existing_variable=num2cell(randi(10,1,100),1);
find(matrix==cell2mat(cell_existing_variable))
If this helps you, its good. Otherwise, I would request you to attach mat file having sufficient varibales.
  8 件のコメント
Joseph Corry
Joseph Corry 2021 年 3 月 16 日
Okay, thank you. I am using the online app
ANKUR KUMAR
ANKUR KUMAR 2021 年 3 月 16 日
I doubt whether xlswrite works in online app or not. xlswrite is working well in MATLAB2017b (which I am using). @MathWorks Support Team

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

その他の回答 (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