%
%
%
%
% Sample rates in excess of 10 times the highest frequency in the signal are typically chosen so that the frequencies of interest are minimally affected by the non-ideal zero order hold. The larger the sampling frequency relative to the frequencies of interest, the less amplitutde will be changed by the zero-order hold.
%
% Fix above. M(t) should blow up immediately
% e(t) has a spectrum amplitude of infinity at zero, but because of sampling effects, this will also be seen at every harmonic of the sampling frequency. The Zero-Order-Hold will then have a much larger signal per sample than the real signal e(t), as e*(t) will have aliasing included. c(t) will be slightly smaller thanks to the low pass filter, but will still capture several multiples of the sampling frequency, and have a much larger signal than e(t)
%
%
%

s = tf('s')
B = 10;
T = 1/1;
G = 1/(1 + (s/2*pi*B));
E = 1/s^2

%% Define the frequency range
omega1 = 1/T;       % Placeholder: maximum frequency (rad/s). Replace as needed.
nPoints = 10000;    % Number of frequency points
omega = linspace(-3*omega1, 3*omega1, nPoints);  % Linearly spaced frequency vector

%% Compute the frequency response
% Evaluate G(j*omega) over the specified range. 
% freqresp returns a multidimensional array; use squeeze to get a vector.
H = squeeze(freqresp(E, 1j*omega));

%% Plot the Magnitude and Phase Spectrum

% Create a figure with two subplots for magnitude and phase
figure;

% Magnitude Plot
subplot(2,1,1);
plot(omega, abs(H), 'b', 'LineWidth', 1.5);
xlabel('\omega (rad/s)');
ylabel('Magnitude');
title('Magnitude Spectrum of G(s)');
grid on;

% Phase Plot
subplot(2,1,2);
plot(omega, angle(H), 'r', 'LineWidth', 1.5);
xlabel('\omega (rad/s)');
ylabel('Phase (radians)');
title('Phase Spectrum of G(s)');
grid on;