extracting row and column from a cell which contains numbers and strings

1 回表示 (過去 30 日間)
Catherine Branter
Catherine Branter 2018 年 11 月 20 日
編集済み: Jan 2018 年 11 月 20 日
I have a 120x11 cell called "mymatrix" and I am trying to extract the data from the row which has the minimum value in column 11
I can get the minimum value of row 11 by converting the cell to a matrix, but then I can't get the rest of the info for that row (from columns 1-10 because i get an error
errorvals = cell2mat(mymatrix(:,11))
minoferrorvals = min(errorvals)
[rowofmin colofmin] = find(mymatrix == minoferrorvals);
The error is this:
Undefined function 'eq' for input arguments of type 'cell'.
Error in work (line 137)
[rowofmin colofmin] = find(mymatrix == minoferrorvals);

回答 (2 件)

Stephen23
Stephen23 2018 年 11 月 20 日
編集済み: Stephen23 2018 年 11 月 20 日
You don't need to use find, just get the second output from min:
errorvals = cell2mat(mymatrix(:,11))
[minoferrorvals,idx] = min(errorvals)
mymatrix(idx,:)

Jan
Jan 2018 年 11 月 20 日
編集済み: Jan 2018 年 11 月 20 日
errorvals = cell2mat(mymatrix(:, 11))
[~, minIndex] = min(errorvals);
result = mymatrix(minIndex, 1:10);
Do you have a good reason for working with a cell?

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by