How to create a 100x1 vector variable called b such that the vector b is equal to -5

1 view (last 30 days)
Create a 100x1 vector variable called b such that the vector b is equal to -5
  3 Comments

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 31 Aug 2016
One approach:
b = zeros(100,1);
b(:) = -5;
Another approach:
b(1:100,1) = -5;
Another approach:
b = -5 * ones(100,1);

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!