AppendixesAppendix A1 %% Main program <strong>for</strong> the frequency analysis <strong>of</strong> data acquired from accelerometers23 %% Define parameters4 step = 2;5 rangeW = 2:step:20;6 filterType = ’butter’;7 order = 10;8 axis = 3;9 plotOpt = 2;10 accOpt = 1;11 tRange = ’middle’;12 %tRange = 0.5:0.001:(0.5+2ˆ11/1000);13 fRange = [1,50];14 nPeaks = 3;15 conf = ’OnWheel−noFrame−concrete’;1617 %% Declare cells and matrices18 nData = length(rangeW);19 data = cell(1,nData);20 dataFFT = cell(1,nData);21 dataLowFilt = cell(1,nData);22 dataLowFiltFFT = cell(1,nData);23 dataFilt = cell(1,nData);24 time = cell(1,nData);25 freq = cell(1,nData);26 fPeak = zeros(nData,nPeaks,3);27 peak = zeros(nData,nPeaks,3);28 fMax = zeros(nData,3);29 amplitude = zeros(nData,3);3031 %% Parse data and find peak frequencies32 <strong>for</strong> i=rangeW
Appendixes 993334 fileName = [’v0−w’,num2str(i),’−t20−’,conf,’.xlsx’];3536 [data{i/step},time{i/step},dataFFT{i/step},freq{i/step}] = ...37 parseData(fileName,accOpt,0,tRange,fRange);38 % plotData(data{i/step},time{i/step},dataFFT{i/step},freq{i/step},...39 % fileName,plotOpt,fRange);4041 dataLowFilt{i/step} = filterData(data{i/step},’low’,filterType,order,fRange);4243 amplitude(i/step,:) = (max(dataLowFilt{i/step})−min(dataLowFilt{i/step}))/2;4445 [dataLowFiltFFT{i/step},freq{i/step}] = computeFFT(dataLowFilt{i/step},tRange);46 plotData(dataLowFilt{i/step},time{i/step},dataLowFiltFFT{i/step},freq{i/step},...47 fileName,plotOpt,fRange);4849 [fPeak(i/step,:,:),peak(i/step,:,:),dataFilt{i/step}] = ...50 findPeakFreq(dataLowFilt{i/step},dataLowFiltFFT{i/step},freq{i/step},...51 filterType,order,fRange,nPeaks);52 fMax(i/step,:) = squeeze(fPeak(i/step,1,:));5354 figure,hold on;55 plot(time{i/step},data{i/step}(:,axis));56 plot(time{i/step},dataLowFilt{i/step}(:,axis),’−g’,’LineWidth’,2);57 plot(time{i/step},dataFilt{i/step}(:,axis)+dataLowFiltFFT{i/step}(1,axis),...58 ’−r’,’LineWidth’,2);5960 if accOpt == 161 ylabel(’Acceleration (m/sˆ2)’);62 else63 ylabel(’Data (V)’);64 end65 xlabel(’Time (s)’);66 title([’Data "’,fileName,’", fPeak = ’,num2str(fMax(i/step,axis)),’ Hz’]);67 legend(’Real y−axis data’,’Lowpass−Filtered y−axis data’,’Bandpass−Filtered y−axis data’);68 grid on;6970 end7172 %% Plot peak frequencies and amplitudes with respect to the angular velocity73 figure,plot(fMax,amplitude,’o’,’LineWidth’,2);74 title([conf,’; Max peak freq. VS Amplitude’]);75 xlabel(’fPeaks (Hz)’),ylabel(’Amplitude (V)’);76 legend(’x−axis’,’y−axis’,’z−axis’);77 grid on;7879 figure,plot(rangeW,fMax,’−o’,’LineWidth’,2);