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
4 Comments
If you're facing issues with MATLAB code and need expert assistance, consider reaching out for MATLAB assignment help at www.matlabassignmentexperts.com. Their experts can guide you through debugging and code optimization!
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.