Finding the slope of line

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.

1 Comment

"How can I find it ?"
By the definition of slope: the change in Y divided by the change in X.

Sign in to comment.

 Accepted Answer

If you have points: use slope formula:
m = (y2-y1)/(x2-x1) ;
Or, fit a straight line using polyfit
p = 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:

6 Comments

Sir, how to find slope of data by polyfit, if in my data there is NaN values or empty values(no values).
Pls help by replying.
Shukriya.
p = polyfit(x,y,1) ; using this I am getting a warning:
Warning: Polynomial is not unique; degree >= number of data points.
> In polyfit (line 74)
In pro2 (line 256)
How to rectify it?
where,
x=0.2653
y=0.0336
Just for one point (x,y) you cannot use polyfit. Atleast you need two points to fit a straight-line.
Ok,I got it. Thank you for helping.
can you share a short code for implementation? of polyfit(x,y,1)

Sign in to comment.

More Answers (0)

Categories

Products

Community Treasure Hunt

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

Start Hunting!