Matlab Intro
Matlab Intro
in the plotted figures we must have Fs > 2* (signal frequency). But for "relatively" lower sampling frequencies, although these
frequencies are higher than the minimum required frequencies to not have to alias, it can't be visualized correctly, because
the plot command fills the space between sample points.
1- AM modulation example
Ac = Amplitude of the carrier signal
Yc = Carrier signal
Ym = Message signal
MATLAB CODE
We need to know the amplitude and frequency of the carrier signal and message signal.
So we will ask to user for the Frequency and Amplitude of the carrier signal and message
signal. The frequency of the message signal cannot be greater than the frequency of the
carrier signal. So, if the user entered a frequency of message signal that is greater than the
carrier signal then we will show that invalid. How long the frequency of the message signal
is not less than the frequency of the carrier signal we should reject that. We need a fixed
period for those signals.
We need to find the time domain values. We will find it from the fraction below.
t = 0:0.001:T;
Ym = Am.*sin(2*pi*fm*t);
Make a subplot as 3 by 1 size. Place the message signal (upcoming) to first subplot. Set
the title.
subplot(3, 1, 1);
plot(t, Ym);
title('Message Signal');
Yc = Ac.*sin(2*pi*fc*t);
Place the carrier signal (upcoming) to second subplot. Set the title.
subplot(3, 1, 2);
plot(t, Yc);
title('Carrier Signal');
Z = (Ac + Ym).*Yc;
Place the modulated signal (upcoming) to third subplot. Set the title.
subplot(3, 1, 3);
plot(t, Z, 'r');
title('Modulated Signal');
3. Filter Design
Filter design methods differ primarily in how performance is specified. For “loosely specified” requirements, as in the
first case above, a Butterworth IIR filter is often sufficient.
To design a fifth-order 30 Hz lowpass Butterworth filter and apply it to the data in vector x,
y = filter(b,a,x);
The second input argument to butter specifies the cutoff frequency, normalized to half the sampling frequency (the
Nyquist frequency). Frequency Normalization in the Signal Processing Toolbox All of the filter design functions operate
with normalized frequencies, so they do not require the system sampling rate as an extra input argument. This toolbox
uses the convention that unit frequency is the Nyquist frequency, defined as half the sampling frequency. The
normalized frequency, therefore, is always in the interval 0 ≤ f ≤ 1. For a system with a 1000 Hz sampling frequency, 300
Hz is 300/500 = 0.6. To convert normalized frequency to angular frequency around the unit circle, multiply by π. To
convert normalized frequency back to hertz, multiply by half the sample frequency