Matrix Indexing for calculating slope

3 次查看(过去 30 天)
Ive got 2, 31x1 matrices x and y to represent x and y points
Id like to calculate the slope of the data by using m = y2 - y1/x2 - x1 and average the slopes obtained
My question is how can i use the second and first value of data of both x and y to calculate the slope for each point throughout the whole data set

采纳的回答

David Hill
David Hill 2020-9-20
slope=diff(y)./diff(x);
averageSlope=sum(slope)/length(slope);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by