Best practices for generating vectors with ones, zeros, rand, etc

ones(2), rand(2) etc all do what you want and return a vector. The way to think about it is that the number of arguments you pass to them is the number of dimensions you want the output to have.

9 Likes