How should I do if I want to build a matrix like [1 2 1 2 ......](which length is 10) with two instructions.And one of the instructions is n=10.
I do'nt know how to do it without 'if' and 'for'.

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 2월 27일

0 개 추천

kron(ones(1,10),1:2)

댓글 수: 1

Lee hsuan
Lee hsuan 2019년 2월 27일
Thank you. I forgot this function.Love you dude.

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

추가 답변 (1개)

KSSV
KSSV 2019년 2월 27일

0 개 추천

p = [1 2] ;
n = 10 ;
q = repmat(p,1,n)

댓글 수: 1

Lee hsuan
Lee hsuan 2019년 2월 27일
I think this is the three-instructions solution.If l'm wrong ,please tell me. Thank you.

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

카테고리

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

태그

질문:

2019년 2월 27일

댓글:

2019년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by