How to delete zero components in a vector in Matlab?

前端 未结 7 1731
误落风尘
误落风尘 2020-12-24 05:24

I have a vector for example

a = [0 1 0 3]

I want to turn a into b which equals b = [1 3].

How do I perform this in gen

7条回答
  •  余生分开走
    2020-12-24 06:25

    Why not just, a=a(~~a) or a(~a)=[]. It's equivalent to the other approaches but certainly less key strokes.

提交回复
热议问题