In MATLAB, given a matrix A, I want to create a matrix B containing elements of matrix A as a percentage of the first column elements. The following code does it:
A = randi(5,6);
B = zeros(size(A,1), size(A,2));
for kk = 1:size(A,2)
B(:,kk) = (A(:,kk).*100)./ A(:,1)-100;
end
However, how could I achieve the same result in a single line through vectorization? Would arrayfun be useful in this matter?
iidoesn't do anything, so you can just divide the entire matrix by the first column.