From a matrix creating a vector

조회 수: 1 (최근 30일)
Emilia
Emilia 2022년 7월 24일
댓글: Star Strider 2022년 7월 24일
Hello,
I have matrix
A=[1 7 3 9 4; 8 6 8 9 1; 7 7 7 8]
I need to find the existing numbers from the matrix and create a vector, for example like this Vector1=[1 3 4 6 7 8 9]
and also count the numbers several times, for example like this Vector2=[2 1 1 1 4 3 2]
Thanks for the helpers :)
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2022년 7월 24일
unique and histcounts will help you
Emilia
Emilia 2022년 7월 24일
Thank you !

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

채택된 답변

Star Strider
Star Strider 2022년 7월 24일
Use the unique and accumarray or histcounts functions.
This appears to be homework, so I leave the coding to you.
  댓글 수: 2
Emilia
Emilia 2022년 7월 24일
Thank you !
Star Strider
Star Strider 2022년 7월 24일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by