How a fill an array with the same value

조회 수: 104 (최근 30일)
Federico Ferrara
Federico Ferrara 2020년 8월 17일
댓글: Star Strider 2020년 8월 17일
I would like to fill an array of zeros with all 10s. So for instance,
N=4
V=zeros(N,1)
I want to have V= [10 10 10 10] without writing it manually, how can i do?
thanks

채택된 답변

Star Strider
Star Strider 2020년 8월 17일
Try this:
N=4
V=zeros(N,1) + 10
Note that because of the way you wrote the zeros call, it will be a column vector, not the row vector you posted.
  댓글 수: 2
Federico Ferrara
Federico Ferrara 2020년 8월 17일
Yes, it works, thanks.
Star Strider
Star Strider 2020년 8월 17일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by