Defining a discrete sequence along an arbitrary time axis

2 visualizzazioni (ultimi 30 giorni)
I need to compute the output of the system y[n] = x[−n]. x[n] is of length 1 : 26866, and the y[n] output axis has the same length and goes from -12850 : 13975.
variables:
x[n] = x1,
output axis y[n] = nx,
output sequence = xt
Difficulty is when I encounter the 0 and negative part of the new (reversed) index. I'm not sure where to get values of x1 that correspond to the negative, new indices.
Thank you very much for you time,
Justin
xt = zeros(size(nx)); %define ouput sequence
for nn = 1:length(nx) %convert output axis with negative values to positive sequence
indx = -nx(nn); % New index (reversed nx axis)
if indx > 0 %Indices are positive, so xt takes values of the last x1 indices, until a index of 0
xt(nn) = xt(nn) + x1(indx);
elseif indx <= 0
xt(nn) = ; %Here I'm lost
end
end
xt

Risposte (1)

Rahul
Rahul il 11 Ott 2024
As per the description and code shared by you, I understand that you wish to compute the output of the system 'y[n] = x[-n]' where x[n] is of length 26866.
As per the working of the loop, whenever the variable 'indx' is positive, then 'xt' would take the value of 'x1' directly.
However, if the value of 'indx' would be negative, then 'xt' needs to be mapped to the positive index of x1, which can be done in the following way:
elseif indx <= 0
xt(nn) = x1(26867 + indx); % Map negative index to positive index in x1
end
% This is the 'elseif' condition which can be added to the loop
Hope this helps! Thanks.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by