MATLAB Answers

A basic matlab problem

18 views (last 30 days)
Hello all,
If I want to create a matrix of for example 9.5 with a specific size i.e. [9.5 9.5 .... 9.5], what should I do?

  2 Comments

Ashok jat
Ashok jat on 18 May 2019
x=ones(1,8);
y=9.5*x
Walter Roberson
Walter Roberson on 19 May 2019
This is the same as Fangjun Jiang's solution.

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 5 Sep 2011
A=9.5*ones(3,4)

  1 Comment

Bahareh
Bahareh on 5 Sep 2011
thanks a lot.

Sign in to comment.

More Answers (4)

bym
bym on 5 Sep 2011
m = 9.5*ones(1,15)

  1 Comment

Bahareh
Bahareh on 5 Sep 2011
thanks a lot.

Sign in to comment.


Walter Roberson
Walter Roberson on 5 Sep 2011
A = repmat(9.5,3,4);
or
A(1:3,1:4) = 9.5;

  1 Comment

Bahareh
Bahareh on 6 Sep 2011
Thanks a lot Mr. Walter!

Sign in to comment.


Bao Le
Bao Le on 5 Dec 2019
x = 9.5.*ones(2,5)

  1 Comment

Walter Roberson
Walter Roberson on 5 Dec 2019
This is the same as earlier solutions.

Sign in to comment.


Alejandro Ayala
Alejandro Ayala on 5 Dec 2019
x = 9.5.*ones(2,5)

  1 Comment

Walter Roberson
Walter Roberson on 5 Dec 2019
This is the same as earlier solutions.

Sign in to comment.

Sign in to answer this question.

Tags

Products