I'm attempting to write the following program without any for or while loops:
function [B] = check(A, k)
B = [];
[nrow ncol] = size(A);
for i = 1:nrow
for j = 1:ncol
if mod(A(i,j),k) == 0
B = [B;A(i,j)];
else
B = [B;A(i,j)*k];
end
end
end
Basically this program checks to see if the elements in matrix A are divisible by element k. If A(i,j) is divisible by k, then the element at A(i,j) would be placed in matrix B. If A(i,j) is not divisible by k, then the element at A(i,j) would be multiplied by k and placed in matrix B.