How to compare peaks of two sinusoidal plots

조회 수: 3 (최근 30일)
alexandra ligeti
alexandra ligeti 2021년 7월 16일
댓글: alexandra ligeti 2021년 7월 19일
Hi there,
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.
  댓글 수: 4
alexandra ligeti
alexandra ligeti 2021년 7월 16일
I have tried the findpeaks() function but I only want the positive peaks to be found and not the negative troughs. I want to analyse peaks and troughs independantly.
Star Strider
Star Strider 2021년 7월 16일
What variables did you use to create that plot? (I have not opened it, since .fig files can be slightly exasperating to work with.)
Posting the relevant code would be helpful. What were the rows or columns from which matrices?
.

댓글을 달려면 로그인하십시오.

답변 (1개)

Simon Chan
Simon Chan 2021년 7월 16일
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);
figure(1)
subplot(2,1,1)
plot(time_v,alpha_20);
grid on
hold on
plot(time_v(alpha_max),alpha_20(alpha_max),'go')
plot(time_v(alpha_min),alpha_20(alpha_min),'bo')
ylabel('alpha 20')
xlabel('time v')
subplot(2,1,2)
plot(time_v,Beta_20);
grid on
hold on
plot(time_v(Beta_max),Beta_20(Beta_max),'go')
plot(time_v(Beta_min),Beta_20(Beta_min),'bo')
ylabel('Beta 20')
xlabel('time v')
For Figure 1

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by