rewrite a matrix with maximum values using MATLAB

34 Views Asked by At

Given a matrix A, Write a Matlab function that keeps the maximum of each row and set all the other elements to zero.

I've started the code but I didn't know how to continue. Can anyone help me?

function B=maxmatr(A)

A=input("Enter a Matrix :");

[r, c]=size(A);

for i=1:r

a(i)=max(A, [], 2);

for j=1:c

    B(i,j)=