Expressing DTFTs in terms of one another with similar time domain signals I cam across a question in my DSP book asking this:
1). Express $X_2(e^{j\omega})$ in terms of $X_1(e^j\omega)$ without explicitly computing $X_1(e^{j\omega})$. ($X_1(e^j\omega)$ represents the DTFT of $x_1[n]$)
\begin{align}
x_1[n] &amp;= \left[1 \ 2 \ 2 \ 1\right]\\
x_2[n] &amp;= \begin{cases}
x_1[n] &amp; 0 \leq n \leq 3\\
x_1[n-4] &amp; 4 \leq n \leq 7\\
0   &amp; \text{otherwise}\end{cases}
\end{align}
Here is my code and answer, but Im dont think my answer is correct. What should I be looking for in the time domain graphs that can give clues to the DTFT? ( i know my dtft function needs some work but I will do that next)
Thanks
%% P3.2
% 1). The magnitude plot of X2(jw) should have a similar shape to X1(jw) because
%     they contain the similar frequency components, but part of X2 is just phase
%     shifted, therefore the angle plots might be a bit different. 
% 2). 

n1 = 0:3;
x1 = [1 2 2 1];
stem(n1,x1); axis([0 7 -4 4]);

n2 = 0:7;
x2 = [1 2 2 1 1 2 2 1]; 
%    ( x1[n])(x1[n-4])
figure;
stem(n2,x2); axis([0 7 -4 4]);

k = 0:200;

X1 = dtft(n1,x1,k);

X2 = dtft(n2,x2,k);


function X = dtft(n,x,k)
% DESCRIPTION
%  Performs an approximate Discrete Time Fourier Transform 
%  the approximation is due to the fact that the output is 
%  not continous. ex. X = dtft(n,x,k); 
%  
% NOTE : Only for finite duration signals.
%
% INPUT VARIABLES
%  n = number of samples 
%  x = array containing time domain signal samples
%  k = evenly spaced divisions of omega (frequency)
%
% OUTPUT VARIABLES
%  X = the transformed output
%  Various graphs of signal aspects
%
% REFERENCES
%  Adapted from &quot;Digital Signal Processing Using MATLAB 3rd ed.&quot; - Ingle, V.,
%  Proakis, J. (pg. 65). 
%
% DOCUMENTATION
%  ver 1.0 by Dominic Meads  5/8/2020
%  filename: dtft.m
%
% ENGINEER'S COMMENTS
%  The authors reccommend to use this more as an
%  excersize rather than a full function. As stated above, use the DFT for
%  better results.
%

w = (pi/100)*k;  % calculates the evenly spaced frequencies 
X = x * (exp(-j*pi/100)) .^(n'*k); % calculates the DTFT

magX = abs(X);  % for graphs
angX = angle(X);
realX = real(X);  % divide into real and imaginary parts
imagX = imag(X);

figure('Color', [1 1 1]);
subplot(2,2,1); plot(w/pi,magX); grid off;
xlabel('frequency in units of pi'); title('Magnitude part');
subplot(2,2,2); plot(w/pi,realX); grid off;
xlabel('frequency in units of pi'); title('Real part');
subplot(2,2,3); plot(w/pi,angX); grid off;
xlabel('frequency in units of pi'); title('Angle part');
subplot(2,2,4); plot(w/pi,imagX); grid off;
xlabel('frequency in units of pi'); title('Imaginary part');
end
The problem is asking you to find an analytical expression given $x_1[n]$ and $x_2[n]$. There is no need to compute anything, let alone code it up!
The problem wants you to identify that given the discrete-time domain functions, you use properties of the DTFT to write $X_2(e^{j\omega})$ in terms of $X_1(e^{j\omega})$. You've already identified that $x_2[n]$ contains a shifted version of $x_1[n]$.
You can use the time-shift property which says that if the DTFT of $x[n]$ is $X(e^{j\omega})$ then
$$\mathcal{F}(x[n - m]) = e^{-j\omega m}X(e^{j\omega})$$
Keeping in mind how the domain of $x_2[n]$ is defined, you can use the DTFT properties to express $X_2(e^{j\omega})$ in terms of $X_1(e^{j\omega})$.