A = input('enter matrix: ')

disp('row operation key:')
disp('r1,m,p = multiply r1 by p')
disp('r1,r2,s = switch r1 and r2')
disp('r1,r2,a,p =  add p times r2 to r1')
go = true;

while go

str = input('select row operation (k for key, x for exit): ','s');

if str(1) == 'k'
    disp('row operation key:')
    disp('r1,m,p = multiply r1 by p')
    disp('r1,r2,s = switch r1 and r2')
    disp('r1,r2,a,p =  add p times r2 to r1')
    str = input('select row operation (k for key, x for exit): ','s');
end    
if str(1) == 'x'
    break
end
if str(3) == 'm'
    p = str2num(str(5:length(str)));
    u = str2num(str(1));
    A(u,:) = p*A(u,:)
end
if str(5) == 's'
    u = str2num(str(1));
    v = str2num(str(3));
    r1 = A(u,:);
    r2 = A(v,:);
    A(u,:) = r2;
    A(v,:) = r1;
end
if str(5) == 'a'
    p = str2num(str(7:length(str)));
    u = str2num(str(1));
    v = str2num(str(3));
    r1 = A(u,:);
    r2 = A(v,:);
    A(u,:) = r1 + p*r2;
end
A

end
    
