I have a [50,6] set of data, and need to create two column vectors from it based on whether a piece of data in column 4 has a value or just 0. so if it has a value it returns the first column number that are in column 1, which correspond to the value or the 0. hopefully that make sense.
ex. a =
1 2 5 0
2 9 3 3
3 8 2 0
i need it to return
b = [2]' and c = [1,3]'

 채택된 답변

Walter Roberson
Walter Roberson 2013년 2월 24일

0 개 추천

isz = a(:,4) == 0;
b = a(~isz, 1);
c = a(isz, 1);

댓글 수: 1

Tyler
Tyler 2013년 2월 25일
worked like a charm. This major issue i was having delt with the "~", didn't realize that did something. ill have to look up the ~, thanks again though.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by