Hi Ismael,
I understand that you would like to represent the Fourier transform of a discrete signal in MATLAB.
The code you provided seems to be attempting to compute and plot the Fourier transform of the discrete signal represented by the system “z/(z-1)”. However, there are a few issues in your code:
- The system “Gz” is not defined as a discrete signal. It's defined as a rational function “z/(z-1)”. To compute the Fourier transform of a discrete signal, you need to have the discrete signal in a time-domain representation.
- The “fft” function in MATLAB is used to compute the Discrete Fourier Transform (DFT) of a sequence of data points. It operates on discrete data, not symbolic expressions.
Here's an example of how you can represent the Fourier transform of a discrete signal in MATLAB:
% Define a discrete signal x[n]
n = 0:99; % Define the time indices (e.g., from 0 to 99)
x = sin(0.1*pi*n) + 0.5*sin(0.3*pi*n); % Example discrete signal
% Compute the Discrete Fourier Transform (DFT) of x[n]
X = fft(x);
% Create a frequency vector (in Hz) for plotting
fs = 1; % Sample rate (Hz)
f = (0:length(X)-1) * (fs / length(X));
% Plot the magnitude and phase of the Fourier transform
figure;
subplot(2, 1, 1);
stem(f, abs(X)); % Magnitude
xlabel('Frequency (Hz)');
ylabel('Magnitude');
subplot(2, 1, 2);
stem(f, angle(X)); % Phase
xlabel('Frequency (Hz)');
ylabel('Phase (radians)');
In this example, we define a discrete signal “x[n]” and then use “fft” to compute its DFT. We also create a frequency vector for plotting.
To know more you can refer to the following documentation links:
- Discrete-Time Signals: https://www.mathworks.com/help/dsp/ug/discrete-time-signals.html
- fft: https://www.mathworks.com/help/matlab/ref/fft.html
I hope this helps!