Defining a discrete sequence along an arbitrary time axis

조회 수: 5 (최근 30일)
Justin Gilmore
Justin Gilmore 2021년 10월 13일
답변: Rahul 2024년 10월 11일
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

답변 (1개)

Rahul
Rahul 2024년 10월 11일
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.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by