MATLAB: Finding the slope of line best lineMATLABslopetimevelocity I have to find slope of best line (acceleration). How can I find it ? I couldn't find any datas about it on the internet. Best Answer If you have points: use slope formula:m = (y2-y1)/(x2-x1) ;Or, fit a straight line using polyfitp = polyfit(x,y,1) ;In the above p will be a 2x1 matrix, which gives slope and y intercept.Or, if you have image and want coordinates from there slope use:https://in.mathworks.com/matlabcentral/fileexchange/7173-grabit Related SolutionsMATLAB: Struggling to add the polynomial line n = 10 ;x = 1:n ;y = rand(size(x)) ;p = polyfit(x,y,1) ;yi = polyval(p,x) ; figurehold onplot(x,y,'*r')plot(x,yi,'b')legend('Original Points','Fitted Line') Related Question
Best Answer