Delete max value of a cell array?

Suppose I have the next cell array:
array= {[0.7359]} {[0.7360]} {[1.4726]} {[1.8402]} {[1.4723]} {[0]} {[1.1039]} {[1.1040]}
I want to remove the max value of this cell array, I tried doing it in this way:
array(array==max(array))
But I got this error: Error using max. Invalid data type. First argument must be numeric or logical.
So my array is in a bad format or what can I do?

 採用された回答

Stephen23
Stephen23 2018 年 8 月 7 日
編集済み: Stephen23 2018 年 8 月 7 日

0 投票

"So my array is in a bad format or what can I do?"
Yes it is, if you want to do numeric operations. Storing numeric data in a cell array makes working with that data harder. Numeric arrays are designed to hold numeric data, and let you do numeric operations on them (like finding the maximum).
"...remove the max value of this cell array"
The first step to solving your question is to put the data into a numeric vector (which it should be anyway):
>> vec = [array{:}]; % convert to numeric
>> [~,idx] = max(vec);
>> vec(idx) = []
vec =
0.73590 0.73600 1.47260 1.47230 0.00000 1.10390 1.10400

2 件のコメント

pauldjn
pauldjn 2018 年 8 月 7 日
編集済み: Stephen23 2018 年 8 月 8 日
It worked very nicely thanks
Stephen23
Stephen23 2018 年 8 月 8 日
@PAUL DAMIAN JIMENEZ NUÑO: I hope that it helps!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

質問済み:

2018 年 8 月 7 日

コメント済み:

2018 年 8 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by