필터 지우기
필터 지우기

How do you maintain value order when removing zeros from a matrix?

조회 수: 1 (최근 30일)
Chameleon17
Chameleon17 2015년 6월 2일
댓글: Chameleon17 2015년 6월 2일
Hi,
I am trying to remove zeros from my matrix, so I have one column of dates, but they need to be maintained in the right order.
First_SP = SP_Marker_C(cellfun(@(x) ~isequal(x, 0), SP_Marker_C));
This removes my zeros, it reorders all the dates though, is it possible to remove the zeros but keep them in the original order?
Thanks for any help/advice/direction!

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2015년 6월 2일
편집: Andrei Bobrov 2015년 6월 2일
SP_Marker_C(~cellfun('ischar',SP_Marker_C)) = {[]};
or
SP_Marker_C(cellfun(@(x)x == 0,SP_Marker_C)) = {[]};
  댓글 수: 1
Chameleon17
Chameleon17 2015년 6월 2일
It instructs me to set my uniform output to false for this to work as it's not scalar in uniform output. If you do that, does that hamper future actions where you want a uniform output?

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by