Save the first non-zero value in each column

Hi all
i have a matrix like that
1 0 1
0 1 0
0 0 0
1 0 1
i want to save only the first non zero values in each column and obtain:
1 0 1
0 1 0
0 0 0
0 0 0
How can i do that?
Thank you for the help
Regards

 채택된 답변

madhan ravi
madhan ravi 2020년 8월 20일

0 개 추천

(cumsum(matrix) == 1) .* matrix

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation of 2-D Selections in 3-D Grids에 대해 자세히 알아보기

제품

릴리스

R2019a

태그

질문:

2020년 8월 20일

댓글:

2020년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by