genRCData.m 1.11 KB
Newer Older
1
2
3
4
5
6
7
8
9
% This script generates .mat files for various inputs on
% the RC model. The .mat files have a data variable
%  datRC with three columns:
% 
%       time  V_in    I_capacitor
% 
% Other variables like peak, freq etc are stored for
% relevant inputs.

hazrmard's avatar
hazrmard committed
10
11
duration = 10;
resolution = 0.001;
12
13
N = duration / resolution;
t = 0:resolution:(duration-resolution);
hazrmard's avatar
hazrmard committed
14
noise = 250; % signal-to-noise ratio in dB
15
16
17
peak = 10;  % amplitude of signal
freq = 1;   % frequency of sine signal

hazrmard's avatar
hazrmard committed
18
19
20
21
22
23
% ramp input
in = t' * peak / duration;
% sim_in = [t', awgn(in, noise, 'measured')];
sim_in = [t', in];
data = runSim('RC', sim_in);
save('resRC_ramp.mat', 'data', 'peak', 'resolution');
24
25
26

% sine input
in = sin(2*pi*freq*t') * peak;
hazrmard's avatar
hazrmard committed
27
28
29
30
% sim_in = [t', awgn(in, noise, 'measured')];
sim_in = [t', in];
data = runSim('RC', sim_in);
save('resRC_sine.mat', 'data', 'freq', 'peak', 'resolution');
31

hazrmard's avatar
hazrmard committed
32
33
% combined ramp + sine + noise
in = (t' * peak / duration) + sin(2*pi*freq*t') * peak;
34
sim_in = [t', awgn(in, noise, 'measured')];
hazrmard's avatar
hazrmard committed
35
36
37
38
data = runSim('RC', sim_in);
save('resRC_comb.mat', 'data', 'freq', 'peak', 'resolution');

clear data freq peak N t duration resolution in sim_in