clc; clear; close all;

L = 1e-6;
C = 1e-6;
R = 1;
Vg = 5;

s = tf('s');

Gvd = Vg/(1+s*L/R+L*C*s^2);

h = bodeplot(Gvd);                    % Plot the Bode plot of G(s)
setoptions(h, 'FreqUnits', 'Hz');   % change frequency scale from rad/sec to Hz
set(findall(gcf,'type','line'),'linewidth',2)
grid on;
hold on;

% read simplis simulation results from csv file
data = csvread("simplis.csv", 1, 0);
freq = data(:,1);
mag = data(:,2);
phase = data(:,3);

ax = findobj(gcf, 'type', 'axes');
phase_ax = ax(1);
mag_ax = ax(2);


% append simplis plot to bode plot
plot(phase_ax, freq, phase, 'r--', 'LineWidth', 2);
plot(mag_ax, freq, mag, 'r--', 'LineWidth', 2);
legend('Math', 'Simplis')

