How to find slope of this line

3 次查看(过去 30 天)
I'm trying to find the slope of this linear line but I can't use polyfit because the vectors aren't the same size.
x = [0.0914;0.195;0.292];
y = [-2.89,-3.55,-2.88,-3.10,-3.09,-3.09,-3.28,-3.35;-7.65,-7.75,-7.43,-7.62,-7.60,-7.66,-7.32,-7.68;-11.2,-11.5,-11.6,-11.45,-11.5,-11.5,-11.5,-11.6];
plot(x,y,'o')
grid on
xlabel('Distance-x (m)')
ylabel('Episilon(bottom)/Pj 1/N')
title('Thick Cantilever Negative')
polyfit(x,y,1)

采纳的回答

Jos (10584)
Jos (10584) 2019-5-3
You can create a complete list of x,y pairs by expanding x to the size of y. Looking at your code, I think a single element of x belongs to a row of y, so:
xx = repmat(x(:), 1, size(y,2))
polyfit(xx, y, 1)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics 的更多信息

标签

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by