フィルターのクリア

How to know which values in a cell exceed a threshold

2 ビュー (過去 30 日間)
John Doe
John Doe 2017 年 10 月 10 日
コメント済み: John Doe 2017 年 10 月 10 日
Dear All,
I have a cell array that contains doubles, it's attached to this question (the help file).
I want to have a new column that contains the values that exceed the threshold. For example, my threshold is 280,
My Data Column
  • [24,1464]
  • 1464
  • 1464
  • [24,24]
New Column
  • 1464
  • 1464
  • 1464
  • 0
and so on....but they're next to each other
I tried things like : G= gt(Mydata{:},280);as a start to build on but it gave me an error
also: newV={[Mydata{:}]>280} but that gave me logical values and it evaluated my values separately.
If you have any ideas on how I can do this please let me know,
Thank You,

採用された回答

Matthew
Matthew 2017 年 10 月 10 日
編集済み: Matthew 2017 年 10 月 10 日
You can certainly solve this using cellfun.
Assuming you only ever want one value per row, here's a somewhat loose way to use logicals that does what you want. There's probably a more type safe way to do this.
threshold = 280
output = cellfun(@(x) any(x>threshold)*max(x),Data)
An alternative would be to return all the values in cells.
output = cellfun(@(x) x(x>threshold),Data,'UniformOutput',false)
output(cellfun(@(x) isempty(x), output)) = {0};
  1 件のコメント
John Doe
John Doe 2017 年 10 月 10 日
This works^^ thank you!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by