removing zeros from a matrix

Hey I have a matrix x=[1;2;0;0;0;3;4;5;0;6;0;4;0;6;3;2;1;1;0]; how do I remove the zeros from this matrix?

 采纳的回答

x(x==0)=[]

2 个评论

does this also look at the zeros in values like 10 or 100 or just the value zero alone?
No, just the value of 0. If you need to remove the zeros in everything, it might be easier to convert it to a string, remove the zero characters, and then convert it back to numbers

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by