天天看點

Matlab資料處理(一):歸一化處理

最近在做畢業設計,涉及了不少關于實驗資料處理的方法。這裡介紹一下資料歸一化處理。

其中:ax是實驗采集的加速度值,是關于時間變化的離散數值;讀取資料之後利用巴特沃斯濾波器濾去高頻信号,最後進行可視化和歸一化處理;

%歸一化處理
clear;clc;
%導入資料ax
StepData = xlsread(\'C:\Users\S5 war\Desktop\DataAnalsis\GROUND.xlsx\');
time = StepData(:,1);
ax = StepData(:,2);

%Butterworth濾波
fs = 20;
fc = 2;
Wc = 2*fc/fs;
[b,a] = butter(4,Wc);
SignalFilter = filter(b,a,ax);

%可視化
figure(1);
subplot(2,1,1);
plot(time,SignalFilter,\'b-\');legend(\'ax_1\');xlabel(\'時間\');ylabel(\'加速度\');title(\'歸一化前\');
%歸一化處理
subplot(2,1,2);
nMax = max(SignalFilter); nMin = min(SignalFilter);
ax_norm = (SignalFilter - nMin)/(nMax - nMin);
plot(time,ax_norm,\'r-\');legend(\'ax_2\');xlabel(\'時間\');ylabel(\'加速度\');title(\'歸一化後\');
           

輸出結果:

Matlab資料處理(一):歸一化處理