create a vector of repeated different values and different repetitions

조회 수: 4 (최근 30일)
hello,
i have data that looks like this
Value repetition
1 5
3 2
5 3
6 1
10 4
i want to create a vector that looks like this
1 1 1 1 1 3 3 5 5 5 6 10 10 10 10
so basically, repeats the numbers in Value colum n repititions.
can anyone please help? thanks

채택된 답변

Steven Lord
Steven Lord 2021년 3월 11일
Take a look at the repelem function.
  댓글 수: 1
Mohammad Aljarrah
Mohammad Aljarrah 2021년 3월 11일
편집: Mohammad Aljarrah 2021년 3월 11일
it worked, thanks
z = repelem (a(:,1), b(:,1));
gievn that a and b are column vectors

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by