Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgSystemCSSConfig has a deprecated constructor in /home/paktools/domains/paktools.eu/public_html/plugins/system/cssconfig/cssconfig.php on line 29
PAKtools - Waterfall Diagrams

Example of throughput data and APS spectrum

This is an example script to view the ASD_Beetle_TP_G2 run-up test, contained in the examples of MüllerBBM-VAS PAK 5.8. The ATFX header and data files were converted using PAK2Mat 2.0, available from PAKTools. This script shows a few basic steps to view the content of a MAT-file, plot / play back throughput data and create APS and order APS spectra.

Click here to download the complete script as an M-file.

Contents

1: Load PAK2Mat file into workspace

The MAT-file as converted by PAK2Mat is loaded into the MATLAB® workspace.

close all; clear

load('ExampleASD_Beetle_TP_G2.mat')

2: Display measurement information

File info is displayed from fields in the MeasInfo structure. If available, basic information on the test candidate can be obtained from the TestCandidate structure.

clc

disp('MEASUREMENT INFORMATION')
disp(['Title:        ' Measurements.MeasInfo.Title])
disp(['Created:      ' datestr(Measurements.MeasInfo.Date)])
disp(['User:         ' Measurements.MeasInfo.Division ' - ' Measurements.MeasInfo.Expert])

if ~isempty(Measurements.TestCandidate)
    disp(' '), disp('TEST CANDIDATE INFORMATION')
    disp(['Manufacturer: ' Measurements.TestCandidate.Manufacturer])
    disp(['Model:        ' Measurements.TestCandidate.Model ' ' Measurements.TestCandidate.ModelYear])
    disp(['Engine Type:  ' Measurements.TestCandidate.EngineType])
    disp(['Transmission: ' Measurements.TestCandidate.TransmissionType])
end
MEASUREMENT INFORMATION
Title:        Active Sound Design - Old Beetle Road Measurement, 2nd Gear Runup and Rundown
Created:      27-Apr-2001 12:20:15
User:         Development - Expert B
 
TEST CANDIDATE INFORMATION
Manufacturer: Volkswagen
Model:        New Beetle 1998
Engine Type:  DI Gasoline
Transmission: Manual

3: Display available data sets

The various data sets contained in the MAT-file are inspected. These are available as structures in the DataSets structure array.

disp(' '), disp('AVAILABLE DATA SETS')
for n = 1:numel(Measurements.DataSets)
    DS = Measurements.DataSets(n);
    fprintf('%d %s\n',n,DS.Name);
end
 
AVAILABLE DATA SETS
1 APS
2 Order APS
3 Slow quantity
4 Throughput
5 Integrity
6 Level
7 Compressed

As shown above, a Throughput data set is available as well as APS and Order APS spectra. The Slow Quantity data set contains a vector with the time instances correponding to the tacho tracking parameter (engine speed). Additionally one finds the data sets Integrity, Level and Compressed which are normally not of interest.

4: Plot throughput data

The time data of the first channel is plotted. The channels are found as seperate structures in the array YChannels, while the time axis is obtained from XChannels. The axis labels and figure title are automatically generated based on the quantity, unit, etc. fields present in the data set structures. The sprintf function is used to combine these fields into a meaningful string.

% Choose throughput data set
DS = Measurements.DataSets(4);

% X-channel (time)
XChan = DS.XChannels(1);
t = XChan.Data;

% Y-channel (throughput signal)
YChan = DS.YChannels(1);
y = YChan.Data;
lbl_y = sprintf('%s - %s',YChan.Name,YChan.Description);

% Plot data
figure(1), clf
plot(t,y,'DisplayName',lbl_y)
xlim([t(1) t(end)])

% Set labels and title
xlabel(sprintf('%s (%s)',XChan.Quantity,XChan.Unit));
ylabel(sprintf('%s (%s)',YChan.Quantity,YChan.Unit));
title(DS.Name);

% Show legend
legend show

5: Play back throughput data

The obtained channel can easily be played back on the computer speakers using the built-in soundsc function. The sample rate is derived from the time axis.

f_s = 1/(t(2)-t(1));
soundsc(y,f_s)

6: Plot Auto Power Spectrum

The APS spectrum as calculated by the PAK software is also contained in the MAT-file. The X-axis now represents frequency, whereas an additional Z-axis can be used to depict the time instances of the APS blocks. FFT analysis parameters can be obtained from the Parameters structure such as the acoustical weighting and window type.

% Choose APS data set
DS = Measurements.DataSets(1);

% X-channel (frequency)
XChan = DS.XChannels(1);
f = XChan.Data;

% Z-channel (time)
ZChan = DS.ZChannels(1);
t = ZChan.Data;

% Y-channel (APS values)
YChan = DS.YChannels(1);
Y = YChan.Data;
lbl_Y = sprintf('%s - %s (%s)',YChan.Name,YChan.Quantity,YChan.Unit);

% To dB scale
Y_dB = 20*log10(abs(Y)/2e-5);

% Plot data
figure(2), clf
imagesc(f,t,Y_dB.')
axis xy; xlim([0 2000]); colorbar;

% Set labels and title
xlabel(sprintf('%s (%s)',XChan.Quantity,XChan.Unit));
ylabel(sprintf('%s (%s)',ZChan.Quantity,ZChan.Unit));
title(sprintf('%s (%s window, %s weighting)\n%s',DS.Name, ...
    DS.Parameters.WindowType,DS.Parameters.AcousticalWeighting,lbl_Y));

7: Plot order Auto Power Spectrum

Similarly, an order APS is available. This time, the X-axis holds the orders as determined by the PAK software. Two Z-axes are available: (1) engine speed or (2) instantaneous time. The first is chosen, such that a typical Campbell order plot is obtained. Note that the script can be left almost the same, as the axis labels are automatically determined from information in the MAT-file.

% Choose APS data set
DS = Measurements.DataSets(2);

% X-channel (order)
XChan = DS.XChannels(1);
ord = XChan.Data;

% Z-channel (engine speed)
ZChan = DS.ZChannels(2);
n = ZChan.Data;

% Y-channel (APS values)
YChan = DS.YChannels(1);
Y = YChan.Data;
lbl_Y = sprintf('%s - %s (%s)',YChan.Name,YChan.Quantity,YChan.Unit);

% To dB scale
Y_dB = 20*log10(abs(Y)/2e-5);

% Plot data
figure(3), clf
imagesc(ord,t,Y_dB.')
axis xy; colorbar;

% Set labels and title
xlabel(sprintf('%s (%s)',XChan.Quantity,XChan.Unit));
ylabel(sprintf('%s (%s)',ZChan.Quantity,ZChan.Unit));
title(sprintf('%s (%s window, %s weighting)\n%s',DS.Name, ...
    DS.Parameters.WindowType,DS.Parameters.AcousticalWeighting,lbl_Y));

8: Summary

The entire script as shown here including all comments and markup counts 175 lines. However the raw code to generate all plots is only 49 lines! This illustrates that a PAK2Mat file can easily be used to plot and process data while meta information accompanying the data helps with identifying the various channels, quantities, analysis parameters etc.