function [A,Q1,S,Q2]=matrixgen(n,m,s)
x=size(s);
if m<x(1);
    error('myApp:argChk', 'The number of columns has to be greater or equal than the singular values')
end
if n<x(1);
    error('myApp:argChk', 'The number of rows has to be greater or equal than the singular values')
end
s=sort(s,'descend');
for ii=1:n
    for jj=1:m
        if (ii==jj)&&(jj<=x(1))
            S(ii,jj)=s(jj);
        else
            S(ii,jj)=0;
        end
    end
end
B=randn(n);
[Q1,R]=qr(B); % Q1 is the left Orthogonal matrix %
B=randn(m);
[Q2,R]=qr(B); % Q2 is the right Orthogonal matrix %
A=Q1*S*Q2';
end
