How to repeat first column and join to another column?

조회 수: 3 (최근 30일)
Kris Sarikanoppakhun
Kris Sarikanoppakhun 2021년 3월 27일
댓글: Kris Sarikanoppakhun 2021년 3월 28일
Hello everyone , i'm newbie that need some help
I want to know how to write from [1 2 3 4 22 23 24 43 44 45 64 65] to be
1 2
1 3
1 4
1 22
1 23
1 24
1 43
1 44
1 45
1 64
1 65

답변 (1개)

DGM
DGM 2021년 3월 27일
Here's one approach:
% given a row vector
a=[1 2 3 4 22 23 24 43 44 45 64 65];
B=[repmat(a(1),[length(a)-1 1]) a(2:end)']

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by