MATLAB Answers

Create array with same number

1.534 views (last 30 days)
Fadal Sasse
Fadal Sasse on 10 Aug 2017
Edited: James Tursa on 14 Sep 2018
I have this command z=ones(length(x),1) If I want to change (ones) with 2 or 3 what I should do?

  0 Comments

Sign in to comment.

Answers (2)

José-Luis
José-Luis on 10 Aug 2017
twos = 2.* ones(length(x),1)

  3 Comments

José-Luis
José-Luis on 10 Aug 2017
Please accept the answer that best solves your problem.

Sign in to comment.


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

  0 Comments

Sign in to comment.

Tags


Translated by