The code returns 5 0 0.
I used the debugger. The for loop made 1 0 0; 2 0 0;….; 5 0 0
The goal is to return y = [1 0 0 2 0 0 3 0 0 4 0 0 5 0 0]
x = [1 2 3 4 5];n = 2;% zero = zeros(1,n)
% [x(1) 0 0 x(2) 0 0]
y = [];zero=zeros(1,n);% How can I combine y?
for i = 1:1:length(x) y = [x(i),zero]end
Best Answer