Skip to content
Snippets Groups Projects
Commit 56cb464d authored by Max Nyberg Carlsson's avatar Max Nyberg Carlsson
Browse files

MATLAB script from Zheng

parent 460eedc1
No related branches found
No related tags found
No related merge requests found
% sampling frequence 100 Hz
t = mix1acc.VarName1;
t = t - min(t); % [ms]
tMax = max(t);
accx = mix1acc.VarName2;
accy = mix1acc.VarName3;
accz = mix1acc.VarName4;
power = accx.*accx + accy.*accy + accz.*accz;
powerMax = max(power);
figure()
plot(t, power);
powerFill = filloutliers(power, 'linear', 'percentiles', [0 99.5]);
hold on
plot(t, powerFill);
power = powerFill;
%%
figure()
tiledlayout(2,3)
[idx1,~] = find(t < 39892);
avgpower1 = mean(power(idx1));
disp("The average power of 1st walking is")
disp(avgpower1)
nexttile
plot(t(idx1), power(idx1));
xlim([0, tMax]);
ylim([0, powerMax]);
%%
[idx2,~] = find((39892 < t) & (t < 90843));
avgpower2 = mean(power(idx2));
disp("The average power of 1st jogging is")
disp(avgpower2)
nexttile
plot(t(idx2), power(idx2));
xlim([0, tMax])
ylim([0, powerMax]);
%%
[idx3,~] = find((90843 < t) & (t < 115075));
avgpower3 = mean(power(idx3));
disp("The average power of 2nd walking is")
disp(avgpower3)
nexttile
plot(t(idx3), power(idx3));
xlim([0, tMax])
ylim([0, powerMax]);
%%
[idx4,~] = find((115075 < t) & (t < 144395));
avgpower4 = mean(power(idx4));
disp("The average power of 1st standing is")
disp(avgpower4)
nexttile
plot(t(idx4), power(idx4));
xlim([0, tMax])
ylim([0, powerMax]);
%%
[idx5,~] = find((144395 < t) & (t < 192695));
avgpower5 = mean(power(idx5));
disp("The average power of 2st jogging is")
disp(avgpower5)
nexttile
plot(t(idx5), power(idx5));
xlim([0, tMax])
ylim([0, powerMax]);
%%
[idx6,~] = find((192695 < t) & (t < 234842));
avgpower6 = mean(power(idx6));
disp("The average power of 3rd walking is")
disp(avgpower6)
nexttile
plot(t(idx6), power(idx6));
xlim([0, tMax])
ylim([0, powerMax]);
%%
%moving average
figure()
M = movmean(power, 500); % window size 5 seconds
% M = movmedian(power, 10);
% plot(t, power);
% hold on
plot(t, M);
xlim([0, tMax])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment