Question: I've the following matlab code written by myself, for the low pass filter and the input of x ( t ) . How to get
I've the following matlab code written by myself, for the low pass filter and the input of xt How to get the output, in both time domain and frequency domain, in plot? If possible, how to get the frequency domain of the xt How to get the function of the output in both time domain and frequency domain? All by Matlab. Will upvote if good answer, and vice versa, thank you.
Parameters
fe; Fundamental frequency Hz
T f;
How to convert to fundamental angular frequency rads
omega pi f;
Define the xaxis,
t T : e : T; Time vector for periods
The dc component was obtained from manual solution
DCComponent ;
Initialize the signal
harmonics
ACComponent zerossizet;
Since n Odd Harmonics until the number of harmonics wanted
Therefore, Loop from to X with increment of has syntax as shown
for n ::
The information below was copied directly from manual solution
bn n pi;
ACComponent ACComponent bn sinn omega t;
end
Add the DC component here, because DC component is constant, and don't
need to be looped! Only the AC component is looped
xt DCComponent ACComponent;
figure; This "figure" use only once, so that all subplots appear in fugure
subplot
How to let the line to be blue, and line width to be so that it
is beautiful?
plott xtr 'LineWidth', ;
titleFourier Series Approximation of xt;
xlabelTime s;
ylabelAmplitude;
Since I want to show the y axis from to then following
syntax is used, because I want y to be at center exactly like
the question given, it's put here not infront of "plot" or it
won't work
ylim;
harmonics
ACComponent zerossizet;
Since n Odd Harmonics until the number of harmonics wanted
Therefore, Loop from to X with increment of has syntax as shown
for n ::
The information below was copied directly from manual solution
bn n pi;
ACComponent ACComponent bn sinn omega t;
end
Add the DC component here, because DC component is constant, and don't
need to be looped! Only the AC component is looped
xt DCComponent ACComponent;
subplot
plott xtg 'LineWidth', ;
titleFourier Series Approximation of xt;
xlabelTime s;
ylabelAmplitude;
ylim;
harmonics
ACComponent zerossizet;
Since n Odd Harmonics until the number of harmonics wanted
Therefore, Loop from to X with increment of has syntax as shown
for n ::
The information below was copied directly from manual solution
bn n pi;
ACComponent ACComponent bn sinn omega t;
end
Add the DC component here, because DC component is constant, and don't
need to be looped! Only the AC component is looped
xt DCComponent ACComponent;
subplot
plott xtb 'LineWidth', ;
titleFourier Series Approximation of xt;
xlabelTime s;
ylabelAmplitude;
ylim;
Plotting the Low Pass Filter's Frequency Response Curve
The Cutoff frequency given, in Hz
fc e;
f: e : eThis really need to trial and error to get the smooth curve
Inputting the transfer function derived manually,
Input log instead of log it produces different result
gain logsqrtffc
figure;
plotf gain;
titleFrequency Response Curve of Low Pass Filter, of fc e;
xlabelFrequency kHz;
ylabelGain dB;
grid on;
Since the fc should give a gain of dB theoretically
To verify this, fc and dB line was plotted
How to make matlab to display the gain, and fc calculated?
f means floating decimal,
is where the output would be
before n means the unit, so that i don't need to type units
xlinefcr 'Cutoff Frequency fc 'LabelVerticalAlignment', 'bottom';
yliner dB 'LabelHorizontalAlignment' 'left';
Not used: below
fprintfCutoff frequency fc: f Hz
fc;
fprintfTime constant tau: f seconds
tau;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
