Using ranges in Matlab/Octave matrices
math, matlab, matrix, octave, vector
Solution
You can use the repeat matrix function (`repmat()`). You code would then look like this:
A = repmat( 1:100, 100, 1 );
This means that you're repeating the first argument of `repmat` 100 times vertically and once horizontally (i.e. you leave it as is horizontally).
Problem
Let's say I want to create an 100x100 matrix of which every row contains the elements 1-100 ``` A = [1:100; 1:100; 1:100... n] ``` Obviously forming a matrix is a bad idea, because it would force me to create 100 rows of range 1:100. I think I could do it by taking a 'ones' array and multiplying every row by a vector... but I'm not sure how to do it ``` a = (ones(100,100))*([]) ``` ?? Any tips?