How are you everyone! I need your help to solve this problem :
If I have an image which contains columns with all elements equal to zero , how can delete the columns?
For example , if I have the image
A= [ 1 0 2 3 4 ;0 0 5 4 3 ;5 0 7 6 5;3 0 4 3 0]
How can I delete the second column ? The result I want is
AA=[1 2 3 4 ;0 5 4 3 ;5 7 6 5 ;3 4 3 0]
Any answer will be appreciated Thank you.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 3월 27일
편집: Azzi Abdelmalek 2016년 3월 27일

1 개 추천

A= [ 1 0 2 3 4 ;0 0 5 4 3 ;5 0 7 6 5;3 0 4 3 0]
AA=A(:,any(A))

댓글 수: 2

Or
A(:, ~any(A)) = [];
To actually delete the columns.
majed majed
majed majed 2016년 3월 28일
Thank you brother for your answer

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

추가 답변 (1개)

Muhammad Usman Saleem
Muhammad Usman Saleem 2016년 3월 27일

0 개 추천

A= [ 1 0 2 3 4 ;0 0 5 4 3 ;5 0 7 6 5;3 0 4 3 0]
A =
1 0 2 3 4
0 0 5 4 3
5 0 7 6 5
3 0 4 3 0
A(:,2)=[];
A =
1 2 3 4
0 5 4 3
5 7 6 5
3 4 3 0

카테고리

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

질문:

2016년 3월 27일

댓글:

2016년 3월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by