Answer:
Check the explanation
Step-by-step explanation:
function expansion = expansion(n)
%create a vector to store additional elements between neighboring elements
average_neighbor = 0.5 * (n(1:end-1) + n(2:end));
%creating the longer array "expansion" of zeros
%which has double the length of "average_neighbor"
%and original vector "n" combine.
lenA = length(average_neighbor)*2;
lenN = length(n)*2;
expansion = zeros(1,(lenA+lenN));
%place original vector n and average_neighbor in every second element after the starting point
expansion(1:2:lenN) = n;
expansion(2:2:lenA) = average_neighbor;
%removes 0 in the array
expansion(expansion == 0) = [];
stem(expansion)
end
%Please see the screen shot given below for more clarity