Remove arrays from a cell based on certain conditions

1 回表示 (過去 30 日間)
Joshua Pretorius
Joshua Pretorius 2021 年 11 月 7 日
コメント済み: Scott MacKenzie 2021 年 11 月 7 日
Hi all,
I have a large set of windspeed data where i have grouped data into seperate arrays within a cell based on a lower limit of 20m/s and an upper limit of 30m/s. However, some of the arrays contain data within these limits in a deccedning order (first value in array is 30 and final is 20), which i do not care about. I only care about the arrays where the initial value is 20 and the final value is 30. The raw data is very large and quiet random so each array within the cell is of a different length.
Is there any way i can delete arrays whose first value is greater than the final value?

回答 (1 件)

Scott MacKenzie
Scott MacKenzie 2021 年 11 月 7 日
If x is an array of numeric data, then
if x(1) > x(end)
clear x;
end
will delete the array x if the "first value is greater than the final value", as your question asks.
  2 件のコメント
Joshua Pretorius
Joshua Pretorius 2021 年 11 月 7 日
Hi Scott, thanks for the reply.
I've tried this and a similar approach and i get an error stating Undefined function 'gt' for input arguments of type 'cell'.
I'm not too sure what this error represents.
Scott MacKenzie
Scott MacKenzie 2021 年 11 月 7 日
I didn't expect my answer to be a solution to the larger issue you are working on. It was intended only an answer to the question as posed.
I suggest you post your data and any code you've written thus far that demonstrates the particular problem you are working on. If the data file is overly large, just post a subset of the data.

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

カテゴリ

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