genRCData.m 1.03 KB
Newer Older
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
% 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.

duration = 1000;
resolution = 0.1;
N = duration / resolution;
t = 0:resolution:(duration-resolution);
noise = 25; % signal-to-noise ratio in dB
peak = 10;  % amplitude of signal
freq = 1;   % frequency of sine signal
bias = 3;   % bias of offset sine signal

% constant input
in = ones(N,1) * peak;
sim_in = [t', awgn(in, noise, 'measured')];
datRC = runSim('RC', sim_in);
save('resRC_const.mat', 'datRC', 'peak', 'noise');

% sine input
in = sin(2*pi*freq*t') * peak;
sim_in = [t', awgn(in, noise, 'measured')];
datRC = runSim('RC', sim_in);
save('resRC_sine.mat', 'datRC', 'freq', 'peak', 'noise');

% combined constant + sine
in = bias + sin(2*pi*freq*t') * peak;
sim_in = [t', awgn(in, noise, 'measured')];
datRC = runSim('RC', sim_in);
save('resRC_comb.mat', 'datRC', 'freq', 'peak', 'bias', 'noise');