You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

21 lines
640 B

#
# Copyright 2022 Philipp Schönberger - mail@phschoen.de
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See <http://www.gnu.org/licenses/>.
function [angle_1,angle_2] = calc_angle_switch(idx,range,X,Y,Z)
angle_1 = 0;
angle_2 = 0;
fitvars = polyfit(Y([idx-range:idx+range]), Z([idx-range:idx+range]), 1);
m = fitvars(1)
c = fitvars(2)
angle_1 = atand(m)
plot (Y([idx-range:idx+range]),Y([idx-range:idx+range]).*m+c);
end