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

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

3 Comments

What does a vector of numbers being equal to a single number mean to you? The sum is equal to -5? Each element is equal to -5? Something else?
How would I solve Ax=b? What would be the approach?
Use the \ operator. For example,
A = rand(5,8);
b = -5 * ones(5, 1);
A\b

Sign in to comment.

Answers (1)

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 Mathematics in Help Center and File Exchange

Asked:

on 30 Aug 2016

Commented:

on 1 Sep 2016

Community Treasure Hunt

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

Start Hunting!