Split a vector where NaN appears

10 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 NaNs 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by