How to compare peaks of two sinusoidal plots
5 views (last 30 days)
I would like to compare the peaks of two sinusoidal plots, the one being motionsense (MS) and the other from Vicon. This mimics a pendulum swinging and the data is captured by two different systems. I would like to compare the data from the two different systems by comparing the peaks for Vicon and MotionSense at each point as the data is not time synchronised.
The workspace has all the files opened so you do not need to run the open files file. But rather firstly run the create markers file and then the plotting file once the workspace has been opened.
VicRef- is the reference vector for vicon when the rod is hanging straight down at rest. This is used to measure the change of angle against.
VicDyn - are all the dynamic trials for vicon. The first number in the name is at what angle the rod was released and the second number is the trial number. For example, VicDyn_5_3 is the vicon dynamic trial number 3 released from 5 degrees.
Sen_StaRef- is the reference vector for the motionsense sensor when the rod is hanging stationary.
Sen_Dyn - is the dynamic trials for the sensor, where the first number is the angle from which the pendulum is released from and the second number is the trial number. For example Sen_Dyn_10_1 is trial 1 of the motionsense dynamic trial, released at 10 degrees.
If you need any help deciphering anything let me know.
alpha_20 = is the angle plotted for vicon for the trial released at 20 degrees.
while New_MS_20 is the angle for motionsense when the pendulum rod is dropped from 20 degrees.
I would like to compare the peaks for the alpha angles (Vicon) against the peaks of the new_MS angles.
Please would someone be able to advise a method as there are 7 different angles to compare peaks against, so would like to do a peak comaprison for each angle and then there are also three trials for each angle so would also like to make comparisons against each trial as well.
Thank you so much.
If I need to clarify anything please let me know,
Just a bit lost as to how to find and compare peaks.
Simon Chan on 16 Jul 2021
Use function islocalmax and islocalmin, but it requires lots of observation from the previous figures in order to get a correct number of peaks or threshold value.
The following code find the local maxima and minima for figure 1 only, others can be generated using similar method.
alpha_max = islocalmax(alpha_20,'MinSeparation',1.5,'SamplePoints',time_v,'MinProminence',0.1);
alpha_min = islocalmin(alpha_20,'MinSeparation',1.5,'SamplePoints',time_v,'MinProminence',0.1);
Beta_max = islocalmax(Beta_20,'MinSeparation',1.5,'SamplePoints',time_v,'MinProminence',0.005);
Beta_min = islocalmin(Beta_20,'MinSeparation',1.5,'SamplePoints',time_v,'MinProminence',0.005);