# Mapping a shifted and sequence to a given output axis

I have a sequence x1, which is the same length of an output vector (nx). However, the output vector goes from -12890:13975. I need to define the output (y[n]) of the system along the axis (nx). I used circshift( ) and made conditions for replacing the back/front fill of the shifted array with zeros, according to the direction of the shift. I think the output might be correct, but I doubt the output is defined along the output axis properly. is the system. Input is x1. Output vector is nx. I've arbitrarily chosen shifts of -30:30 to test plot. Thank you

x1 = x1';
y = zeros(1,length(nx));
k_vals = -30:30;
for k_idx = 1:length(k_vals)
k=k_vals(k_idx);
x = circshift(x1,Nb*k);
if k<0
x(end + k: end) = 0;
elseif k==0;
elseif k > 0;
x(1:k)=0;
end
y = y + (Ab^k).*x;
end

• Thanks for your quick response. Downscaling the variables & trying to implement the offset. Getting an error "left/right hand sides have different number elements": x1 = [8 6 5 6 4 2 0 9 0 0 8 5 7 3 1 2 3 4 2 1 6 0 4 7 2 0]; nx = -12:13; Nb = 3; Ab = 0.75; indexRange = [-12 13]; yOffset = -indexRange(1)+1; y = zeros(indexRange(2)-indexRange(1)+1,1); k_vals = -3:3; for k_idx = 1:length(k_vals) i=k_vals(k_idx); y(i+yOffset) = (Ab^i).*x1(x1 - Nb*i); %<----ERROR HERE end  Oct 18 at 16:22

You don't need to do anything special OTHER then manually using a offset constant for indexing the time shifted array. Do NOT move the actual data. If you must, you can create a class that supports arbitrary indexing but this would be significantly less efficient and more complicated than the "manual offset" method.

%% example for arbitray indexing
indexRange = [-30 30];
yOffset = -indexRange(1)+1; % -30 is the start index, 1 is Matlab array offset
y = zeros(indexRange(2)-indexRange(1)+1,1);

% build a ramp
for i = -30:30
y(i+yOffset) = i; % index with offset
end

% plot it
xaxis = indexRange(1):indexRange(2);
plot(xaxis,y);
grid('on');