How can I remove (set to NaN) values in matrix starting at row index value and all following values which differ for each column

1 回表示 (過去 30 日間)
I have two matrices (kz and zdr) of equal size [997 x 359]. I want to find the first value for each column in zdr>3.5 and use the index to set kz=NaN, but I want all following rows to be equal to NaN as well regardless of their value in zdr.
example: a=-4; b=5; zdr=(b-a).*rand(959,359) + a; kz=randn(997,358);
[mie_rows,mie_cols]=find(zdr>3.5) mie=[mie_rows,mie_cols];
so in my case the first column [23,1] is the first row beyond 3.5. I would therefore like kz from row 23 and beyond to be NaN, the next column is [1,2], from row 1 and beyond of kz is NaN, and etc...
  1 件のコメント
Amir
Amir 2014 年 8 月 4 日
Please try this code. I hope it works for you
a=-4; b=5; zdr=(b-a).*rand(959,359) + a; kz=randn(997,359); for i=1:size(zdr,2) kz(min(find(zdr(:,i)>3.5))+1:end,i)=NaN; end

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

採用された回答

Amir
Amir 2014 年 8 月 4 日
Please try this code. I hope it works for you
a=-4; b=5; zdr=(b-a).*rand(959,359) + a; kz=randn(997,359);
for i=1:size(zdr,2)
kz(min(find(zdr(:,i)>3.5))+1:end,i)=NaN;
end
  2 件のコメント
Brandon
Brandon 2014 年 8 月 4 日
Thanks for the help works perfectly
Brandon
Brandon 2014 年 8 月 4 日
one quick edit, the +1 keeps the first value of >3.5, when I didnt want that. Guess I wasnt to clear. Removing the +1 works fine though.

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

その他の回答 (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