MATLAB: Generating a matrix question

columncommandmatrixrow

i want to generate a matrix that each element is the sum of its row and column ive tried usin the henkel command but it didnt work is there an alternative or more simple solution thx

Best Answer

A=zeros(3,4);
[ii,jj]=ind2sub(size(A),1:numel(A));
A(1:end)=sum([ii' jj'],2)