omit zeros from matrix and have the shape of matrix

조회 수: 8 (최근 30일)
NA
NA 2019년 4월 14일
답변: Kevin Rawson 2019년 4월 14일
A=[0,0;0,0;0,0;1,2;2,5;5,7;7,8];
I want to omit zero from this matrix. result should be
New_A=[1,2;2,5;5,7;7,8];
I use this code
A(A==0) = [];
But giving me array.

채택된 답변

Kevin Rawson
Kevin Rawson 2019년 4월 14일
If you are trying to get rid of rows with zeros:
A(all(A == 0, 2), :) = [];

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by