splitting a periodic sweeping matrix

I have a matrix that goes from a negative value to a positive value through 0 and then from a positive value to negative value . This is repeated for 100 times. How do i divide the matrix so that i get all the negative sweeps in one matrix and all the positive sweep in another. For example see the attached file.

답변 (1개)

Matt J
Matt J 2014년 11월 25일

0 개 추천

neg=A(A<=0);
pos=A(A>0);

댓글 수: 2

DebiPrasad
DebiPrasad 2014년 11월 25일
hey Thanks Matt, but i don't need the matrix to be only containing negative and positive values, but sweeps. What i mean is first vector will have values -2 to 2 thats a sweep . another vector will contain the sweep of 2 to -2.
Matt J
Matt J 2014년 11월 25일
편집: Matt J 2014년 11월 25일
idx=diff(A)>0;
idx=[idx(1), idx];
pos_sweeps=A(idx);
neg_sweeps=A(~idx);

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2014년 11월 25일

편집:

2014년 11월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by