필터 지우기
필터 지우기

How to shuffle an array?

조회 수: 3 (최근 30일)
faa nad
faa nad 2013년 6월 4일
Hi ,
I want to concatenate two arrays by shuffling in the following format.I used randperm it keeps on changing the array position.i need to maintain a static position for it.
a=[1 2 3 4 5]; b=[10 20 30 40 50]; if 'a' and 'b are two individual arrays say,then the concatenated array must be as follows
c=[1 10 2 20 3 30 4 40 5 50]

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 6월 4일
편집: Andrei Bobrov 2013년 6월 4일
reshape([a;b],1,[]);
or
out = zeros(1,numel(a)*2);
out(1:2:end) = a;
out(2:2:end) = b;
  댓글 수: 1
faa nad
faa nad 2013년 6월 4일
thank u sir,

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

추가 답변 (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