MATLAB: How To Efficiently Remove NaN Elements from Matrix

后端 未结 5 1059
猫巷女王i
猫巷女王i 2020-12-05 01:13

I am looking for a way to remove the NaN numbers from a matrix in MATLAB efficiently (i.e. without using a for loop)

I will provide a quick example to illustrate wha

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 01:21

    try my snip function. I wanted to address typical questions like this in one simple function:

    B = snip(A,nan)
    

    you can find the function file at

    It also works with all other 'x', '0' or whatever elements and takes care of more similar problems.

提交回复
热议问题