Split a vector where NaN appears

11 ビュー (過去 30 日間)
Marc Cowan
Marc Cowan 2021 年 4 月 5 日
編集済み: dpb 2021 年 4 月 5 日
I have many m*3 vectors, and for some of them, they are say, between rows p and q, (which are different for each vector) a number of NaN values in the first column. In these instances, I wish to split them into two vectors, one which contains all rows up to p, and one which contains all rows after q.
To clarify, all the NaN values appear between rows p and q, and there are no values which I wish to keep within these rows.

採用された回答

dpb
dpb 2021 年 4 月 5 日
編集済み: dpb 2021 年 4 月 5 日
>> x=randn(10,1);x([4 7])=nan
x =
0.5080
0.2820
0.0335
NaN
1.1275
0.3502
NaN
0.0229
-0.2620
-1.7502
>> [pq]=[find(isnan(x),1)-1 find(isnan(x),1,'last')+1]
pq =
3 8
>>

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by