forked from lucasselvik/Linear-Dynamical-Model-RLC-Circuits
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompetitionTest.m
More file actions
56 lines (39 loc) · 1.23 KB
/
competitionTest.m
File metadata and controls
56 lines (39 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%% Case study 3: Circuits as Resonators, Sensors, and Filters
% *ESE 105*
%
% *Name: Rex Paster & Lucas Selvik*
clear;
close all;
Fs = 192000; % Sampling frequency, Hz
%% Task 1: Tuning fork
Vpulse = zeros(length(0:(1/Fs):5),1); % 5-second duration
Vpulse(2) = 1;
Vringing = myResonatorCircuit(Vpulse,1/Fs);
soundsc(Vringing,Fs);
%% Task 2: Audio sensor
load('MarsHelicopter_noisy.mat');
% set sampling interval to match sampling rate of the audio signal
h = 1/Fs;
% compute signal output from circuit
VsoundFiltered = mySensorCircuit(Vsound,h);
% compare power spectra
plotPowerSpectrum(Vsound,Fs);
plotPowerSpectrum(VsoundFiltered,Fs);
% play original sound
playSound(Vsound,Fs);
% play sound after circuit filter
playSound(VsoundFiltered,Fs);
%% Task 3: Music filter
% load('handel.mat');
load('noisyhandel.mat');
% set sampling interval to match sampling rate of the audio signal
h = 1/Fs;
% compute signal output from circuit
VsoundFiltered = myFilterCircuit(Vsound,h);
% compare power spectra
plotPowerSpectrum(Vsound,Fs);
plotPowerSpectrum(VsoundFiltered,Fs);
% play original sound
playSound(Vsound,Fs);
% play sound after circuit filter
playSound(VsoundFiltered,Fs);