Created
January 8, 2015 13:26
-
-
Save haxelion/04781a22911e587131d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% f : frequency array | |
% a : amplitude array | |
% p : phase array | |
% pm : phase margin | |
% fp : phase margin frequency | |
% str : title of the plot | |
function phasegainplot(f, a, p, Pm, Fp, str) | |
figure; | |
subplot(2, 1, 1); | |
semilogx(f, a); | |
hold on; | |
plot([1, Fp], [0, 0], 'r-'); | |
plot([Fp, Fp], [0, -60], 'r:'); | |
title(str); | |
ylabel('Amplitude (dB)'); | |
xlabel('Frequency (Hz)'); | |
subplot(2, 1, 2); | |
semilogx(f, p); | |
hold on; | |
plot([Fp, Fp], [0, -180], 'r:'); | |
plot([Fp, Fp], [Pm-180, -180], 'r-'); | |
ylabel('Phase (deg)'); | |
xlabel('Frequency (Hz)'); | |
hold off; | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = readtable('resultats\Results\Avd_db.csv'); | |
f = table2array(data(:, 'freq_Hz_')); | |
amp = table2array(data(:, 'Avd_dB_dB_')); | |
data = readtable('resultats\Results\Avd_phase.csv'); | |
phase = table2array(data(:, 'Avd_phase_deg_')); | |
i = closest(0, amp); % function that find the index of the elemend of amp closest to 0, had to write it. | |
phasegainplot(f, amp, phase, phase(i)+180, f(i), 'Spectre Simulation Bode Plot'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment