MATLAB Examples

## Detecting a Cracked Cylinder Head

We have data captured from a flight recorder in a small aircraft. Measurements were taken every 6 seconds, and include: * Timestamp * Exhaust Gas Temperature (EGT) * Cylinder Head Temperature (CHT) * Maximum EGT Difference Between Cylinders * Oil Temperature * And a few others that we won't be using

```% Some excellent references on Engine Monitor Data Analysis: % * https://www.savvyanalysis.com/articles % * https://www.savvyanalysis.com/articles/understanding-cht-and-egt ```

## Create datastore to access collection of files

```ds = datastore('data\','NumHeaderLines',1); ```

The full data set is only ~1MB, so load it all into memory. If we had too much data to load into memory at once, we could load a chunk by executing: t_chunk = read(ds);

```t = readall(ds); ```

## Convert Date and TIME columns to a single column of type datetime

```t.TIME = datetime(strcat(t.Date,t.TIME),'InputFormat','MM/dd/yyHH:mm:ss'); t.Date = []; ```

## Visualize the Exhaust Gas Temperature (EGT)

```figure; tripBreak = 10; % number of seconds without data that denotes a new trip plotTrips(tripBreak,t.TIME,t{:,{'E1','E2','E3','E4'}}); ylabel('EGT (^oF)'); legend('EGT1','EGT2','EGT3','EGT4'); ```

## Visualize the Cylinder Head Temperature (CHT)

```figure; plotTrips(tripBreak,t.TIME,t{:,{'C1','C2','C3','C4'}}); ylabel('CHT (^oF)'); legend('CHT1','CHT2','CHT3','CHT4'); ```

## Try to discern the faulty cylinder by looking at EGT Difference

```figure; plotTrips(tripBreak,t.TIME,t.DIF); ylabel('EGT Difference (^oF)'); ```

## Dig into EGT Difference a bit more - any curious cylinders?

```figure; ax1 = subplot(2,1,1); plotTrips(tripBreak,t.TIME,t.DIF); ylabel('EGT Max Diff (^oF)'); ax2 = subplot(2,1,2); plotTrips(tripBreak,t.TIME,t{:,{'E1','E2','E3','E4'}}); ylabel('EGT (^oF)'); legend('EGT1','EGT2','EGT3','EGT4') linkaxes([ax1,ax2],'x'); ```

## Calculate the rolling standard deviation of EGT

```figure; n = 4; for i = 1:n window = 10^i; B = rollingstdev(t(:,{'E1','E2','E3','E4'}),window); subplot(n,1,i); plot(B); title(['Rolling Std Dev, Window Size = ' num2str(window)]); end legend('EGT1','EGT2','EGT3','EGT4'); ```