Setting Array Value

조회 수: 3 (최근 30일)
Mohamed mohamed
Mohamed mohamed 2011년 6월 22일
Hello Guys I have really rather simple question: I want to set an array value into the follow [1, 3, 1, 7;1, 3, 1, 7;1, 3, 1, 7] and I used the following command a(1:3,1:3)=[1 3 1 7] But it is not working. Any clues ? Thank you.

채택된 답변

Matt Fig
Matt Fig 2011년 6월 22일
Another:
A = repmat([1,3,1,7],3,1) % change the 3 to 5 to get 5 rows, etc...

추가 답변 (1개)

Paulo Silva
Paulo Silva 2011년 6월 22일
r=[1 3 1 7]
a=[r;r;r]
or
r=[1 3 1 7]
b=ones(4,1)*r
b=b(1:3,:)
or
r=[1 3 1 7]
repmat(r,3,1)
  댓글 수: 2
Mohamed mohamed
Mohamed mohamed 2011년 6월 22일
Thank you Paul but I was looking for more Generic Answer what is the number of columns was 100 or any other number how to set them all in to r ?
Paulo Silva
Paulo Silva 2011년 6월 22일
Use the repmat function to replicate rows

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

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by