MATLAB: Hi. I am a complete novice at matlab and have been asked to create a 10×10 matrix in as few steps as possible. The first row has to be from 1:10, the second line from 2:11 and so on. How to create this using repmat

colonhomeworkMATLABmeshgridrepmatreshape

%this is the matrix I want to achieve
A = zeros(10)
A(1,:)=[1:10]
A(2,:)=[2:11]
A(3,:)=[3:12]
A(4,:)=[4:13]
A(5,:)=[5:14]
A(6,:)=[6:15]
A(7,:)=[7:16]
A(8,:)=[8:17]
A(9,:)=[9:18]
A(10,:)=[10:19]
%How can I achieve this using repmat, reshape or meshgrid and the colon
%operator?

Best Answer

(1:10)+(0:9)'