Commit 10ec7673 authored by hazrmard's avatar hazrmard
Browse files

added RC circuit w/ parasitic capacitance

parents
Loading
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+6 −0
Changes for .gitignore: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
*.ini
*.autosave
*.slxc
*.asv
*.mat
slprj
 No newline at end of file

PhysicalModels/RC.slx

0 → 100644
+23.6 KiB

File added.

No diff preview for this file type.

+35 −0
Changes for PhysicalModels/genRCData.m: 35 added lines, 0 removed lines.
Original line number Diff line number Diff line
% 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');
 No newline at end of file
+16 −0
Changes for PhysicalModels/runSim.m: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
function results = runSim(model, sim_in)
% Runs a Simulink model. The `model` takes as input
% a workspace variable `sim_in` which is a matrix where
% the first column is a time stamp and the remaining
% columns are individual inputs. The model outputs to
% a workspace variable `sim_out` which is a timestamp
% object.
% The function parses the `sim_out` and returns `result`
% in the same form as `sim_in`.
stop_t = sim_in(end,1);
steps = diff(sim_in(:, 1));
minStep = min(steps(:));
set_param(model, 'StopTime', num2str(stop_t), 'MaxStep', num2str(minStep));
sim(model);
results = [sim_out.Time sim_out.Data];
end

README.md

0 → 100644
+5 −0
Changes for README.md: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Data Driven Models

Using data to augment physical system models.

See [docs/](/docs/) for details.
 No newline at end of file
Loading