how to find slope for certain area in graph.

1 回表示 (過去 30 日間)
Eirikur Bernharðsson
Eirikur Bernharðsson 2019 年 10 月 19 日
コメント済み: John D'Errico 2019 年 10 月 19 日
I have this graph and i need to find the slope where is (2 - 14)
clear all;clc;
gogn = xlsread(fullfile('C:\Users\ebben\Dropbox\HR\Eðlisfræði\Verklegt\Top','TOP_gogn.xlsx'));
force=gogn(:,1);
angle=gogn(:,2); % Data imported
% finding the slope
lm=fitlm(angle,force,'poly1');
hallatala=lm.Coefficients.Estimate;
% value for slope in textbox
annotation('textbox', [.3 .245 .1 .1], 'String', ...
['Hallatala: ',num2str(hallatala(2,1))]);
% ploting data
plot(angle,force,'r.')
hold on
% ploting the slope line
besta_lina=hallatala(2,1)*angle + hallatala(1,1);
plot(angle,besta_lina,'k','Linewidth',2)
xlabel('angle[rad]');
ylabel('force[N]');
grid
title(['TOP'])
  2 件のコメント
Adam Danz
Adam Danz 2019 年 10 月 19 日
It looks like you've alread found the slope. Is there a question missing?
Be careful using linear regresion on circular data.
Here are your data in polar coordinates.
191019 100725-Figure 1.png
John D'Errico
John D'Errico 2019 年 10 月 19 日
Adam has put a different spin on things, but it seems like circular reasoning. ;-P

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2019 年 10 月 19 日
To limit ‘angle’ (and ‘force’) to calculate the slope only on the ‘angle’ limits between 2 and 14, try this:
Lv = (angle >= 2) & (angle <= 14); % Logical Vector Selecting Desired Subset
angle = angle(Lv); % Limit ‘angle’
force = force(Lv); % Limit ‘force’
inserting these assignments just after you initially define them.
I am not certain if you want to limit your entire analysis to those limits, or just plot that line and return the slope value in that region. Both of those are relatively straightforward to do.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by