function ans = your_fcn_name(n)
n;
j=sum(1:n);
a=zeros(1,j);
for i=1:n
a(1,((sum(1:(i-1))+1)):(sum(1:(i-1))+i))=i.*ones(1,i);
end
disp
3 Comments
correct `disp` into `disp(a)`
nothing wrong. Just change disp to disp(a)
There's nothing wrong with it, as such, but your function's output argument is called ans, not a. If you change that to a, it should work.
Two more observations: 1) n; doesn't do anything, and 2) the final disp without an argument will give you an error.