필터 지우기
필터 지우기

Custom Vector - make vector x to be [1,1,....]

조회 수: 1 (최근 30일)
Steve
Steve 2011년 10월 6일
Hello Experts,
I want to create a vector x where all n elements are for example c.
I can do this by:
n=5;
x=zeros(1,n);
x(x==0) = 1;
But how to do this in more simple way.
Thanks a lot!

채택된 답변

Walter Roberson
Walter Roberson 2011년 10월 7일
repmat(c,1,n)
or
c * ones(1,n)
or
c + zeros(1,n)
or
c(ones(1,n)) %yes, even with scalar c
  댓글 수: 1
bym
bym 2011년 10월 7일
+1 for the last one. The force is strong in you

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

추가 답변 (1개)

bym
bym 2011년 10월 6일

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by