MATLAB Answers

0

Calculating Angle Between Two Vectors / Three Points

Asked by Jacob Richardson on 25 Mar 2019
Latest activity Answered by Teja Muppirala
on 26 Mar 2019
So I have some raw data from an experiment (plotted below) which exhibits hysteresis behaviour. I would like to locate and highlight the points on the plot where there are sharp changes in direction.
So far I have tried three things: converting points to vectors and using cross/dot product to calculate the angle between two vectors; calculating the radius of curvature along three consecutive data points and lastly going back to basics and using the Cosine rule in groups of three data points. In each case I have created a cruder plot of the raw data using the RPD algoritm (see below) and attempted to identify the significant changes in direction by assigning a minimum curvature/angle etc.
I'm aware there are some versions of this topic already covered but I still seem to be missing something.
In each of these attempts the outputted angles are not what is expected i.e. angles that appear to be at ~ 90 deg on the plot are output as close to 2-3 deg etc. and hence lots of the flatter sections of the plots are picked up by the markers.
The desired points that I am aiming to pick up are shown below, although I understand a few others may be picked up in the process this is ok, as I'm mostly aiming to eliminate the markers currently picked up along the flat section of the plot.
I would appreciate any assistance anyone can offer, I've included my raw data, m files for angle calcs and for smoothing the data if anyone would like to look.
RAW DATA
RawData.PNG
After RPD Algorithm is Applied
RPD Algorithm Applied.PNG
Example of Markers Highlighted (from 'AnglesUsingVectors' Script)
Markers Highlighted.PNG
Desired Marker Locations
DesiredMarkers.PNG

  0 Comments

Sign in to comment.

1 Answer

Answer by Teja Muppirala
on 26 Mar 2019
 Accepted Answer

The units on the axes are very different. Displacement is around +/- 3 while shear is around +/- 80, so the calculated angles from the data will not match at all what they appear to be on the graph. You may want to scale the variables to be roughly equal in magnitude first (for example by using ZSCORE or whatever) and then redo the angle calculation and you may get more reasonable values.

  0 Comments

Sign in to comment.