How to find slope of this line

5 ビュー (過去 30 日間)
jaad shahout
jaad shahout 2019 年 5 月 3 日
回答済み: Jos (10584) 2019 年 5 月 3 日
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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by