loop-function to count each angle and compare to the previous one
1 view (last 30 days)
Show older comments
Hello!
I have got some data and calculated the regression lines at every sixth datapoint. I am able to compute the angle between the first three lines, using this script:
ax=x1(1,2)-x1(1,1); %first (a) vector
ay=y1(1,2)-y1(1,1);
bx=x1(1,3)-x1(1,2); %second (b) vector
by=y1(1,3)-y1(1,2);
cx=x1(1,1)+ax+bx; %resulting, leading to third vector
cy=y1(1,1)+ay+by;
lcx=x1(1,3)-x1(1,1); %third (c) vector
lcy=x1(1,3)-x1(1,1);
Ba=sqrt((ax^2+ay^2)); % norm (a)
Bb=sqrt((bx^2+by^2)); % norm (b)
Bc=sqrt((lcx^2+lcy^2)); % norm (c)
alpha1=acosd(Bc^2-Bb^2-Ba^2-(2.*Ba.*Bb)); %angle in between vector a & b = a1 on the pic
Now I want to use a function that loops this, so I can calculate each angle as you can see in the picture (a1,a2,a3,....an). In a next step, I want to compare the angles with each other to find the curvature. I am not so familiar doing loops. Can you think of a loop that fits?
Thanks a lot!

0 Comments
Answers (0)
See Also
Categories
Find more on Linear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!