フィルターのクリア

Find negative in every n rows

1 回表示 (過去 30 日間)
David du Preez
David du Preez 2017 年 5 月 12 日
コメント済み: Andrei Bobrov 2017 年 5 月 15 日
I have a 2184 x 14 matrix. In column 1 is the datenum value and in column 14 the values that I want to consider. The other columns contain some other data.
I want to consider the first 24rows if any of the values in column 14 are negative. I want to delete the first 24rows and then repeat this for the following 24rows.

採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 5 月 12 日
編集済み: Andrei Bobrov 2017 年 5 月 15 日
One way
% A - your data [2184 x 14]
ii = ceil((1:size(A,1))'/24);
jj = accumarray(ii,A(:,14),[],@(x)all(x >= 0)); % EDIT
out = A(jj(ii),:);
  2 件のコメント
David du Preez
David du Preez 2017 年 5 月 15 日
編集済み: David du Preez 2017 年 5 月 15 日
That does not work. It does not find any negative neither removes them. attached in the matrix in question
Andrei Bobrov
Andrei Bobrov 2017 年 5 月 15 日
I'm fixed my answer.

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

その他の回答 (1 件)

Jan
Jan 2017 年 5 月 15 日
編集済み: Jan 2017 年 5 月 15 日
Data = rand(2184, 14) - 0.1; % Test data
D = reshape(Data, 24, [], 14);
Match = any(D(:, :, 14) < 0, 1);
Result = reshape(D(:, Match, :)), [], 14);

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by