# # 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 . 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