How to find slope of this line
조회 수: 4 (최근 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)
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!