Skip to content
Snippets Groups Projects
Verified Commit b5cba1ed authored by Thomas Lambert's avatar Thomas Lambert :helicopter:
Browse files

feat(analysis): start result analysis

parent 070f736e
No related branches found
No related tags found
No related merge requests found
function ResData = resultsanalysis(matFiles)
% RESULTSANALYSIS Analysis of the different results obtained
% Todo
% ----------------------------------------------------------------------------------------------
% (c) Copyright 2022 University of Liege
% Author: Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% MIT License
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all;
clc;
addpath(genpath('.'));
% Defaults and constants
persistent matFiles_
persistent ResData_
PLOT_RES = false;
FORCE_RELOAD = false;
if (isempty(matFiles_) || ~strcmp(matFiles_, matFiles)) && ~FORCE_RELOAD
% Load data
allFiles = dir(matFiles);
for iFile = 1:numel(allFiles)
resFile = fullfile(allFiles(iFile).folder, allFiles(iFile).name);
tmp = load(resFile);
ResData(iFile, :) = tmp.ExpData;
end
ResData = rmfield(ResData, {'arduStart', 'tunnelStart'});
% Cache values to prevent excessive reloads
matFiles_ = matFiles;
ResData_ = ResData;
else
ResData = ResData_;
end
idx = findwingphase(ResData(1, 1), 0);
end
function idx = findwingphase(ResData, phase)
% FINDWINDPHASE Return the indexes where the wings are at a certain phase
% Todo
% ----------------------------------------------------------------------------------------------
% (c) Copyright 2022 University of Liege
% Author: Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% MIT License
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Find flapping frequencies and period from data
trueFreq(1) = getmainfrequency(ResData.front.arduShort(:, 1), ResData.front.arduShort(:, 2));
trueFreq(2) = getmainfrequency(ResData.aft.arduShort(:, 1), ResData.aft.arduShort(:, 2));
% Determine period offset that match phase
% Find peaks in the wing angles
% Find indexes with proper phase difference
idx = 0; % FIXME, proper return
end
function trueFreq = getmainfrequency(time, signal)
% GETFREQUENCIES Return the main signal frequencies
% Constants and defaults
DEBUG = false;
% Signal parameters
dt = diff(time);
sampling = 1 / dt(1);
if mod(length(signal), 2) ~= 0
signal = signal(1:end - 1);
end
nts = length(signal);
% Fourier transform
transform = fft(signal);
fT2 = abs(transform / nts); % Two-sided spectrum
fT1 = fT2(1:nts / 2 + 1); % Single-sided spectrum
fT1(2:end - 1) = 2 * fT1(2:end - 1);
freq = sampling * (0:(nts / 2)) / nts; % Frequency domain
% Get main frequency
[~, trueFreqIdx] = max(fT1);
trueFreq = freq(trueFreqIdx);
if DEBUG
figure;
plot(freq, fT1);
title("Single-Sided Amplitude Spectrum of S(t)");
xlabel("f (Hz)");
ylabel("|P1(f)|");
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment