Hi everyone I am going to attempt that query: Write a function called divvy that takes a matrix A of positive integers and a single positive integer k as its two inputs and returns a matrix B that has the same size as A. The elements of B are all divisible by k. If an element of A is divisible by k, then the corresponding element in B must have the same value. If an element of A is not divisible by k, then the corresponding element of B must be the product of the given element of A and k. You are not allowed to use any for-‐loops or while-‐loops. For example, the call X = divvy([1 2 ; 3 4], 2) would make X equal to [2 2 ; 6 4]. I am using that codes
function B =divvy(A,k)if rem(A,k)==0 B=A;else B=A(:,:)*k;endend
but getting that error..
Feedback: Your function made an error for argument(s) [1 4;5 2;6 0], 3 Your solution is _not_ correct.
Any suggestion how can i correct my code? thanks in advance for assistance
Best Answer