Create new vector from data - Counts of element locations in vector
이전 댓글 표시
I have kind of a strange specific need for transforming my data to use in a script a colleague has sent me. I'm new to MATLAB, so changing my data should be easier than rearranging the guts of the code.
What I need is to change a vector of numbers (between 0 and 5) to a new vector with 'counts' of the location of the number in the original vector. That's confusing, so for an example:
x = [0,1,0,2,0,3,0,1,1,4]
would become:
y = [2,4,4,6,6,6,8,9,10,10,10,10]
Where the first '2' in y is the location of the '1' at the second location in vector x, etc.
Other than a subset of the find and sum functions, I'm stumped. Thanks in advance for any help, I'm still familiarizing myself with the software.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!