I want array value not 0 keep to new array ?
r = img(:,:,1); g = img(:,:,2); b = img(:,:,3);
% double aa; double aa;
AR = [r];
[i,j] = size(AR);
for i = 1:j
if (AR(i) ~= 0)
aa = [AR(i)]
end
end

 채택된 답변

Jan
Jan 2013년 11월 19일

0 개 추천

To get the non-zero elements of an array simply do something like:
A = randn(100, 100);
A_non_zero = A( A~=0 );
This stores the non-zero elements of matrix A in the array A_non_zero.

댓글 수: 1

Tanakorn Tiay
Tanakorn Tiay 2013년 11월 20일
thank you ^_^ ขอบคุณครับ

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2013년 11월 19일

댓글:

2013년 11월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by