ok lets say i have a vector A = (1 1 2 2 3 4 4 4 4 5 7 7 7) the original A vector was related to actual time, hence why its increasing....i've already used the ceil function to bucket the original elements into distinct minutes... now i want to count up the elements that occur in distinct minutes.. so, for the example above- I expect a final result of 6....i cant figure out how to come up with that code.. please help

 채택된 답변

Matt J
Matt J 2021년 5월 8일
편집: Matt J 2021년 5월 8일

0 개 추천

numel(unique(A))
or
max(findgroups(A))

댓글 수: 4

Matt J
Matt J 2021년 5월 8일
James Bakers' comment moved here
thanks perfect
Matt J
Matt J 2021년 5월 8일
You are very welcome, but pleae Accept-click the answer to indicate that it resolved your question.
James Baker
James Baker 2021년 5월 9일
matt,
hopefully, you don't mind a follow up question? given my A vector above in the oroginal question, what woule by the syntax to create a 2nd vector? this 2nd vector would have the values in it as follows B = (2 2 1 4 5 3). this represents the count of each unique value in the original A vector such as 2 1's, 2's, 1 3, 4 4's, 1 5 and 3 7's.and so on
James Baker
James Baker 2021년 5월 9일
whoops he B vector should be (2 2 1 4 1 3)... not (2 2 1 4 5 3)... doh!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 5월 8일

댓글:

2021년 5월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by