% ParallelRLC_script.m -->  with ParallelRLC.mdl
% script for Simulink model of RLC series circuit%
%
% For EGR 326 Class example Sept 2013
% Author: J Cardell

% Set parameter values and input signal
R1 = 1;       % R in Ohm
L1 = 0.25;    % L in H
C1 = 1;       % C in F
iS = 1;       % Current source

% Define initial conditions for iL and vC
iL_0 = 0;
vC_0 = 0;

% run the simulink model
set_param('ParallelRLC','StartTime','0','StopTime','15')
sim('ParallelRLC');

% define data vectors written to Matlab workspace by Simulink 'To
% Workspace' block
t = iS_in.time;
u = iS_in.signals.values;
y = iL_out.signals.values;


% Create and label plot of circuit behavior
figure
hold on

plot(t, u, 'r-', 'LineWidth', 2)
plot(t, y, 'LineWidth', 2)
title('Parallel RLC Circuit, with iL as output')
xlabel('t (sec)')
ylabel('iL (A)')
grid

hold off