I have this command z=ones(length(x),1) If I want to change (ones) with 2 or 3 what I should do?

 채택된 답변

James Tursa
James Tursa 2018년 9월 14일
편집: James Tursa 2018년 9월 14일

6 개 추천

See this link for a discussion of various methods to do this:
The fastest method seems to be
z = zeros(length(x),1) + 2;

추가 답변 (2개)

José-Luis
José-Luis 2017년 8월 10일

19 개 추천

twos = 2.* ones(length(x),1)

댓글 수: 3

Fadal Sasse
Fadal Sasse 2017년 8월 10일
Thanx
José-Luis
José-Luis 2017년 8월 10일
Please accept the answer that best solves your problem.
PY SUN
PY SUN 2018년 9월 14일
Thanks

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

Drue
Drue 2023년 2월 22일

0 개 추천

To create arrays with the same number I'd personally just set a variable and put it in the linspace function
x = 3
poof = input('how many columns of this number do you want?')
linspace(x,x,poof)

카테고리

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

태그

질문:

2017년 8월 10일

답변:

2023년 2월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by