i have A= 1 0 1 0 0 0 1 and B= 1 1 1 0 0 0 1 now i need to make it as s= 1 1 0 1 1 1 0 0 0 0 0 0 1 1 can any please help me

 채택된 답변

Matt Fig
Matt Fig 2011년 6월 23일

0 개 추천

A = [1 0 1 0 0 0 1];
B = [1 1 1 0 0 0 1];
s = reshape([A;B],1,[])

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 6월 23일

0 개 추천

s= zeros(1,numel(A)+numel(B))
s(2:2:end) = B;
s(1:2:end) = A;
?

댓글 수: 5

mahaveer hanuman
mahaveer hanuman 2011년 6월 23일
i have A and B now i need to make it as s=(A,B) how can i do it
A and B are above values
Walter Roberson
Walter Roberson 2011년 6월 23일
s = horzcat(A,B);
or alternately
s = [A,B];
Matt Fig
Matt Fig 2011년 6월 23일
The s shown in the example is not a simple concatenation.
Walter Roberson
Walter Roberson 2011년 6월 23일
But the solution you gave below is the same effectively solution as Sean already gave, which Mahaveer was replying to. I took Mahaveer's "now i need" as indicating Mahaveer needed something _different_ now.
Matt Fig
Matt Fig 2011년 6월 23일
Oh, I took it as that he didn't understand Sean de's solution because he had it in his mind that there was going to be some 'reshaping' done...

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by