modify scripts

This commit is contained in:
Thomas Dehaeze 2021-06-03 18:00:04 +02:00
parent b5262379c8
commit bbc29dd5fe
6 changed files with 83 additions and 42 deletions

View File

@ -9,28 +9,33 @@ addpath('./src/');
% Test with one APA % Test with one APA
%% Load measurement data for APA number 1 %% Load measurement data for APA number 1
load(sprintf('mat/frf_data_%i.mat', 1), 't', 'Va', 'Vs', 'de', 'da'); load(sprintf('mat/frf_data_%i_sweep_lf.mat', 2), 't', 'Va', 'Vs', 'de', 'da');
% Time domain data:
figure;
plot(t, de);
% Compute transfer functions: % Compute transfer functions:
Ts = (t(end) - t(1))/(length(t)-1); Ts = (t(end) - t(1))/(length(t)-1);
Fs = 1/Ts; Fs = 1/Ts;
win = hanning(ceil(0.5*Fs)); % Hannning Windows win = hanning(ceil(1*Fs)); % Hannning Windows
[G_dvf, f] = tfestimate(Va, de, win, [], [], 1/Ts); [G_dvf, f] = tfestimate(Va, de, win, [], [], 1/Ts);
[G_d, ~] = tfestimate(Va, da, win, [], [], 1/Ts); [G_d, ~] = tfestimate(Va, da, win, [], [], 1/Ts);
[G_iff, ~] = tfestimate(Va, Vs, win, [], [], 1/Ts); [G_iff, ~] = tfestimate(Va, Vs, win, [], [], 1/Ts);
[coh_dvf, ~] = mscohere(Va, de, win, [], [], 1/Ts);
[coh_d, ~] = mscohere(Va, da, win, [], [], 1/Ts);
[coh_iff, ~] = mscohere(Va, Vs, win, [], [], 1/Ts);
%%
figure;
hold on;
plot(f, coh_dvf);
plot(f, coh_d);
plot(f, coh_iff);
hold off;
set(gca, 'XScale', 'log');
%%
figure; figure;
tiledlayout(2, 1, 'TileSpacing', 'None', 'Padding', 'None'); tiledlayout(2, 1, 'TileSpacing', 'None', 'Padding', 'None');
@ -42,7 +47,6 @@ hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log'); set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude $V_{out}/V_{in}$ [V/V]'); set(gca, 'XTickLabel',[]); ylabel('Amplitude $V_{out}/V_{in}$ [V/V]'); set(gca, 'XTickLabel',[]);
hold off; hold off;
ylim([10, 30]);
ax2 = nexttile; ax2 = nexttile;
hold on; hold on;
@ -65,7 +69,6 @@ plot(f, abs(G_iff));
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log'); set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude $V_{out}/V_{in}$ [V/V]'); set(gca, 'XTickLabel',[]); ylabel('Amplitude $V_{out}/V_{in}$ [V/V]'); set(gca, 'XTickLabel',[]);
hold off; hold off;
ylim([10, 30]);
ax2 = nexttile; ax2 = nexttile;
plot(f, 180/pi*angle(G_iff)); plot(f, 180/pi*angle(G_iff));
@ -75,7 +78,7 @@ hold off;
yticks(-360:90:360); yticks(-360:90:360);
linkaxes([ax1,ax2],'x'); linkaxes([ax1,ax2],'x');
xlim([5, 5e3]); xlim([0.1, 10]);
% Comparison of all APA % Comparison of all APA

BIN
matlab/frf_data.mat Normal file

Binary file not shown.

Binary file not shown.

View File

@ -26,7 +26,10 @@ t = data(:, end); % Time [s]
% And we save this to a =mat= file: % And we save this to a =mat= file:
apa_number = 1; apa_number = 1;
% leg_number = 4;
save(sprintf('mat/frf_data_%i_huddle.mat', apa_number), 't', 'Va', 'Vs', 'de', 'da'); save(sprintf('mat/frf_data_leg_coder_%i_noise.mat', apa_number), 't', 'Va', 'Vs', 'de', 'da');
% save(sprintf('mat/frf_data_leg_coder_%i_sweep.mat', apa_number), 't', 'Va', 'Vs', 'de', 'da');
% save(sprintf('mat/frf_data_leg_coder_%i_noise_hf.mat', apa_number), 't', 'Va', 'Vs', 'de', 'da');
% save(sprintf('mat/frf_data_leg_coder_%i_add_mass_closed_circuit.mat', apa_number), 't', 'Va', 'Vs', 'de', 'da');

View File

@ -16,23 +16,6 @@ Trec_dur = 100; % Recording Duration [s]
Tsim = 2*Trec_start + Trec_dur; % Simulation Time [s] Tsim = 2*Trec_start + Trec_dur; % Simulation Time [s]
%% Sweep Sine
gc = 0.1;
xi = 0.5;
wn = 2*pi*94.3;
% Notch filter at the resonance of the APA
G_sweep = 0.2*(s^2 + 2*gc*xi*wn*s + wn^2)/(s^2 + 2*xi*wn*s + wn^2);
V_sweep = generateSweepExc('Ts', Ts, ...
'f_start', 10, ...
'f_end', 1e3, ...
'V_mean', 3.25, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'sweep_type', 'log', ...
'V_exc', G_sweep*1/(1 + s/2/pi/500));
%% Shaped Noise %% Shaped Noise
V_noise = generateShapedNoise('Ts', 1/Fs, ... V_noise = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 3.25, ... 'V_mean', 3.25, ...
@ -41,28 +24,79 @@ V_noise = generateShapedNoise('Ts', 1/Fs, ...
'smooth_ends', true, ... 'smooth_ends', true, ...
'V_exc', 0.05/(1 + s/2/pi/10)); 'V_exc', 0.05/(1 + s/2/pi/10));
%% Sweep Sine
gc = 0.1;
xi = 0.5;
wn = 2*pi*92.7;
% Notch filter at the resonance of the APA
G_sweep = 0.2*(s^2 + 2*gc*xi*wn*s + wn^2)/(s^2 + 2*xi*wn*s + wn^2);
V_sweep = generateSweepExc('Ts', Ts, ...
'f_start', 10, ...
'f_end', 400, ...
'V_mean', 3.25, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'sweep_type', 'log', ...
'V_exc', G_sweep*1/(1 + s/2/pi/500));
V_sweep_lf = generateSweepExc('Ts', Ts, ...
'f_start', 0.1, ...
'f_end', 10, ...
'V_mean', 3.25, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'sweep_type', 'log', ...
'V_exc', 0.2);
%% High Frequency Shaped Noise
[b,a] = cheby1(10, 2, 2*pi*[300 2e3], 'bandpass', 's');
wL = 0.005*tf(b, a);
V_noise_hf = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 3.25, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'smooth_ends', true, ...
'V_exc', wL);
%% Sinus excitation with increasing amplitude %% Sinus excitation with increasing amplitude
V_sin = generateSinIncreasingAmpl('Ts', 1/Fs, ... V_sin = generateSinIncreasingAmpl('Ts', 1/Fs, ...
'V_mean', 3.25, ... 'V_mean', 3.25, ...
'sin_ampls', [0.1, 0.2, 0.4, 1, 2, 4], ... 'sin_ampls', [0.1, 0.2, 0.4, 1, 2, 4], ...
'sin_period', 1, ... 'sin_period', 1, ...
'sin_num', 5, ... 'sin_num', 5, ...
't_start', 10, ... 't_start', Trec_start, ...
'smooth_ends', true); 'smooth_ends', true);
%% Zero Excitation
% Trec_start = 10; % Start time for Recording [s]
% Trec_dur = 40; % Recording Duration [s]
%
% Tsim = 2*Trec_start + Trec_dur; % Simulation Time [s]
V_zero = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 3.25, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'smooth_ends', true, ...
'V_exc', tf(0));
%% Select the excitation signal %% Select the excitation signal
V_exc = timeseries(V_noise(2,:), V_noise(1,:)); V_exc = timeseries(V_noise(2,:), V_noise(1,:));
%% Plot
figure; figure;
tiledlayout(1, 2, 'TileSpacing', 'Normal', 'Padding', 'None'); tiledlayout(1, 2, 'TileSpacing', 'Normal', 'Padding', 'None');
ax1 = nexttile; ax1 = nexttile;
plot(V_exc(1,:), V_exc(2,:)); plot(V_exc.Time, squeeze(V_exc.Data));
xlabel('Time [s]'); ylabel('Amplitude [V]'); xlabel('Time [s]'); ylabel('Amplitude [V]');
ax2 = nexttile; ax2 = nexttile;
win = hanning(floor(length(V_exc)/8)); win = hanning(floor(length(squeeze(V_exc.Data))/8));
[pxx, f] = pwelch(V_exc(2,:), win, 0, [], Fs); [pxx, f] = pwelch(squeeze(V_exc.Data), win, 0, [], Fs);
plot(f, pxx) plot(f, pxx)
xlabel('Frequency [Hz]'); ylabel('Power Spectral Density [$V^2/Hz$]'); xlabel('Frequency [Hz]'); ylabel('Power Spectral Density [$V^2/Hz$]');
set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log'); set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log');

1
matlab/notes.txt Normal file
View File

@ -0,0 +1 @@
6.39 kg