필터 지우기
필터 지우기

find a value and following values in a matrix

조회 수: 1 (최근 30일)
elisa ewin
elisa ewin 2016년 9월 9일
답변: Andrei Bobrov 2016년 9월 9일
Hi, I have a matrix
A= [23 34 45 0 0 0; 21 34 0 0 23 11; 34 23 0 0 0 22]
I want to find if a value is present and if it's present, I want to find the following values.
Eg I want to find in A the value 23, if it's present I want like output a matrix only with 23 and its following values
B= [23 34 45 0 0 0; 0 0 0 0 23 11; 0 23 0 0 0 22]
Can you help me? thanks

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 9월 9일
out = (cumsum(A == 23,2)>0).*A

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by