b=rand(1,10)
n=roots([1,1,-2*numel(b)]);
n=n(n>0)+1;
validateattributes(n,{'numeric'},{'positive', 'integer'}) %numel(b) must be a pyramidal number
C=tril(ones(n),-1);
C(logical(C))=b;
C=C+C.'+eye(n)
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!