vector_magnitude computes the vector magnitude value for each sample (row) of a multi-channel signal.

vector_magnitude(df, axes = NULL)

Arguments

df

dataframe. multi-channel signal, with the first column being the timestamp in POSXct format.

axes

numerical vector. Specify the column indices for each axis. When this value is NULL, the function assumes the axes are starting from column 2 to the end. Default is NULL.

Value

dataframe. The transformed dataframe will have the same number of rows as input dataframe but only two columns, with the first being timestamps and second being the vector magnitude values.

Details

This function takes a dataframe of a multi-channel signal as input, and then computes the 2-norm (vector magnitude) for each row and returns a transformed dataframe with two columns.

How is it used in MIMS-unit algorithm?

This function is not used in the released version of MIMS-unit algorithm, but was used to compare the alternative sum_up method when combining MIMS-unit values on each axis into a single value.

See also

sum_up

Other transformation functions: compute_orientation(), sum_up()

Examples

# Use the first 10 rows of the sample data as an example df = sample_raw_accel_data[1:10,] df
#> HEADER_TIME_STAMP X Y Z #> 1 2016-01-15 11:00:00.013 0.148 -0.438 0.016 #> 2 2016-01-15 11:00:00.025 0.215 -0.418 -0.023 #> 3 2016-01-15 11:00:00.038 0.266 -0.402 -0.012 #> 4 2016-01-15 11:00:00.049 0.336 -0.430 0.012 #> 5 2016-01-15 11:00:00.062 0.430 -0.320 0.000 #> 6 2016-01-15 11:00:00.075 0.535 -0.258 0.004 #> 7 2016-01-15 11:00:00.088 0.641 -0.348 0.020 #> 8 2016-01-15 11:00:00.099 0.777 -0.418 0.023 #> 9 2016-01-15 11:00:00.112 0.938 -0.359 0.043 #> 10 2016-01-15 11:00:00.125 1.113 -0.234 0.055
# By default, the function will assume columns starting from 2 to be axial # values. vector_magnitude(df)
#> HEADER_TIME_STAMP MAGNITUDE_X_Y_Z #> 1 2016-01-15 11:00:00.013 0.4626057 #> 2 2016-01-15 11:00:00.025 0.4706145 #> 3 2016-01-15 11:00:00.038 0.4821867 #> 4 2016-01-15 11:00:00.049 0.5458388 #> 5 2016-01-15 11:00:00.062 0.5360037 #> 6 2016-01-15 11:00:00.075 0.5939739 #> 7 2016-01-15 11:00:00.088 0.7296472 #> 8 2016-01-15 11:00:00.099 0.8825996 #> 9 2016-01-15 11:00:00.112 1.0052731 #> 10 2016-01-15 11:00:00.125 1.1386615
# Or, you may specify the column indices yourself vector_magnitude(df, axes=c(2,3,4))
#> HEADER_TIME_STAMP MAGNITUDE_X_Y_Z #> 1 2016-01-15 11:00:00.013 0.4626057 #> 2 2016-01-15 11:00:00.025 0.4706145 #> 3 2016-01-15 11:00:00.038 0.4821867 #> 4 2016-01-15 11:00:00.049 0.5458388 #> 5 2016-01-15 11:00:00.062 0.5360037 #> 6 2016-01-15 11:00:00.075 0.5939739 #> 7 2016-01-15 11:00:00.088 0.7296472 #> 8 2016-01-15 11:00:00.099 0.8825996 #> 9 2016-01-15 11:00:00.112 1.0052731 #> 10 2016-01-15 11:00:00.125 1.1386615
# Or, if you only want to consider x and y axes vector_magnitude(df, axes=c(2,3))
#> HEADER_TIME_STAMP MAGNITUDE_X_Y #> 1 2016-01-15 11:00:00.013 0.4623289 #> 2 2016-01-15 11:00:00.025 0.4700521 #> 3 2016-01-15 11:00:00.038 0.4820373 #> 4 2016-01-15 11:00:00.049 0.5457069 #> 5 2016-01-15 11:00:00.062 0.5360037 #> 6 2016-01-15 11:00:00.075 0.5939604 #> 7 2016-01-15 11:00:00.088 0.7293730 #> 8 2016-01-15 11:00:00.099 0.8822998 #> 9 2016-01-15 11:00:00.112 1.0043530 #> 10 2016-01-15 11:00:00.125 1.1373324
# Or, just return the chosen column vector_magnitude(df, axes=c(2))
#> HEADER_TIME_STAMP MAGNITUDE_X #> 1 2016-01-15 11:00:00.013 0.148 #> 2 2016-01-15 11:00:00.025 0.215 #> 3 2016-01-15 11:00:00.038 0.266 #> 4 2016-01-15 11:00:00.049 0.336 #> 5 2016-01-15 11:00:00.062 0.430 #> 6 2016-01-15 11:00:00.075 0.535 #> 7 2016-01-15 11:00:00.088 0.641 #> 8 2016-01-15 11:00:00.099 0.777 #> 9 2016-01-15 11:00:00.112 0.938 #> 10 2016-01-15 11:00:00.125 1.113