MATLAB: Multiplying all elements by fellow elements

elementmultiply

Dear All, please if i have matrix of [1 2;4 3], i want to write a statement that can multiply every element by their fellow element and give final result in matrix. that is it will perform and give this kind of matrix: [1*1 1*2 1*4 1*3; 2*1 2*2 2*3 2*4] thanks

Best Answer

A=[1 2;4 3] %edited
[m,n]=size(A);
result=cell(1,m);
for i = 1:m
result{i}=[A(1,i).*(A)];
end
result=horzcat(result{:})