How to insert a column/row of ones into a matrix? March 7, 2023 by Tarik An easy inline way to do this is: b = [ones(size(b, 1), 1) b];