39 lines
1.1 KiB
Matlab
39 lines
1.1 KiB
Matlab
function computeFormants(filename)
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
% function computeFormants(filename)
|
|
% ex.: computeFormants("./praat_data/infoFormants.txt")
|
|
%
|
|
% Task: To compute the average formants from a data set extracted from the formant
|
|
% listing tool of the Praat software.
|
|
%
|
|
% Inputs:
|
|
% -filename : String containing the directory of the file to read (.txt).
|
|
%
|
|
% Outputs:
|
|
%
|
|
%
|
|
% Author: Charles Stelandre - charles.stelandre@ecam.fr
|
|
% Date: 01/05/2025
|
|
%
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
data = readtable(filename);
|
|
|
|
% Extract each column into variables named after the headers
|
|
Time_s = data.Time_s;
|
|
F1_Hz = data.F1_Hz;
|
|
F2_Hz = data.F2_Hz;
|
|
F3_Hz = data.F3_Hz;
|
|
F4_Hz = data.F4_Hz;
|
|
|
|
% Compute averages, handling missing or undefined values
|
|
mean_F1_Hz = mean(F1_Hz, 'omitnan');
|
|
mean_F2_Hz = mean(F2_Hz, 'omitnan');
|
|
mean_F3_Hz = mean(F3_Hz, 'omitnan');
|
|
mean_F4_Hz = mean(F4_Hz, 'omitnan');
|
|
|
|
% Display results
|
|
fprintf('Average F1_Hz: %.4f\n', mean_F1_Hz);
|
|
fprintf('Average F2_Hz: %.4f\n', mean_F2_Hz);
|
|
fprintf('Average F3_Hz: %.4f\n', mean_F3_Hz);
|
|
fprintf('Average F4_Hz: %.4f\n', mean_F4_Hz); |