필터 지우기
필터 지우기

I want to remove zeroes from an array. The array more zero per row. For example: a = [200.03 303.56 0 0 0; 155.23 0 0] Should be turned into a = [200.03 303.56; 155.23]

조회 수: 1 (최근 30일)
I want to remove zeroes from an array. The array has exactly mote zero per row. For example:
a = [1 4 3 0 0 0; 1 5 0 0 0; 1 8 1 0 0; 5 4 4 0 0;1 5 2 0 0]
Should be turned into
a = [1 4 3; 1 5 5; 1 8 1; 5 4 4; 1
  댓글 수: 1
KSSV
KSSV 2018년 3월 14일
a = [1 4 3 0 0 0; 1 5 0 0 0; 1 8 1 0 0; 5 4 4 0 0;1 5 2 0 0]
This is not correct......please correct your question properly.

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2018년 3월 14일
a = [1 4 3 0 0 0 1 5 0 0 0 1 8 1 0 0 5 4 4 0 0 1 5 2 0 0]
% b = [1 4 3 1 5 5 1 8 1 5 4 4 1 ] ;
b = a ;
b(a==0) = [] % remove zeros
b = a ;
b(b~=0) % pick non zeroes

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by