Calculating Angle Between Two Vectors / Three Points

조회 수: 4 (최근 30일)
Jacob Richardson
Jacob Richardson 2019년 3월 25일
답변: Teja Muppirala 2019년 3월 26일
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

채택된 답변

Teja Muppirala
Teja Muppirala 2019년 3월 26일
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개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by