3 % Copyright (c) 2015 Samsung Electronics Co., Ltd.
5 % Licensed under the Apache License, Version 2.0 (the "License");
6 % you may not use this file except in compliance with the License.
7 % You may obtain a copy of the License at
9 % http://www.apache.org/licenses/LICENSE-2.0
11 % Unless required by applicable law or agreed to in writing, software
12 % distributed under the License is distributed on an "AS IS" BASIS,
13 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 % See the License for the specific language governing permissions and
15 % limitations under the License.
17 % Sensor Fusion Implementation for Pedometer Estimation
19 % - Input Accelerometer, Gyroscope and Magnetometer sensor data
20 % - Plot results for Pedometer
31 Bias_Az = 10.084 - GRAVITY;
55 Accel_data = zeros(4,BUFFER_SIZE);
56 Gyro_data = zeros(4,BUFFER_SIZE);
57 Mag_data = zeros(4,BUFFER_SIZE);
59 % Sensor Data simulating pedometer motions
61 % get accel x,y,z axis data from stored file
62 Accel_data(1,:) = (((dlmread("accel")(:,1))') - Bias_Ax)(1:BUFFER_SIZE);
63 Accel_data(2,:) = (((dlmread("accel")(:,2))') - Bias_Ay)(1:BUFFER_SIZE);
64 Accel_data(3,:) = (((dlmread("accel")(:,3))') - Bias_Az)(1:BUFFER_SIZE);
65 Accel_data(4,:) = ((dlmread("accel")(:,4))')(1:BUFFER_SIZE);
67 % get gyro x,y,z axis data from stored file
68 Gyro_data(1,:) = (((dlmread("gyro")(:,1))') - Bias_Gx)(1:BUFFER_SIZE);
69 Gyro_data(2,:) = (((dlmread("gyro")(:,2))') - Bias_Gy)(1:BUFFER_SIZE);
70 Gyro_data(3,:) = (((dlmread("gyro")(:,3))') - Bias_Gz)(1:BUFFER_SIZE);
71 Gyro_data(4,:) = ((dlmread("gyro")(:,4))')(1:BUFFER_SIZE);
74 Gyro_data(1,:) = Gyro_data(1,:)/scale_Gyro;
75 Gyro_data(2,:) = Gyro_data(2,:)/scale_Gyro;
76 Gyro_data(3,:) = Gyro_data(3,:)/scale_Gyro;
78 % get magnetometer x,y,z axis data from stored file
79 Mag_data(1,:) = (((dlmread("magnetic")(:,1))') - Bias_Mx)(1:BUFFER_SIZE) * Sign_Mx;
80 Mag_data(2,:) = (((dlmread("magnetic")(:,2))') - Bias_My)(1:BUFFER_SIZE) * Sign_My;
81 Mag_data(3,:) = (((dlmread("magnetic")(:,3))') - Bias_Mz)(1:BUFFER_SIZE) * Sign_Mz;
82 Mag_data(4,:) = ((dlmread("magnetic")(:,4))')(1:BUFFER_SIZE);
85 scrsz = get(0,'ScreenSize');
86 set(hfig,'position',scrsz);
90 p1 = plot(1:length(UA),UA(1,1:length(UA)),'r');
94 p2 = plot(1:length(UA),UA(1,1:length(UA)),'b');
98 p3 = plot(1:length(UA),UA(1,1:length(UA)),'g');
103 p1 = plot(1:length(UA),UA(1,1:length(UA)),'r');
107 p2 = plot(1:length(UA),UA(1,1:length(UA)),'b');
111 p3 = plot(1:length(UA),UA(1,1:length(UA)),'g');
116 p1 = plot(1:length(UA),UA(1,1:length(UA)),'r');
120 p2 = plot(1:length(UA),UA(1,1:length(UA)),'b');
124 p3 = plot(1:length(UA),UA(1,1:length(UA)),'g');