how to draw tangent line simulink graph ?

I would like to plot Tangent Line in Simulink MATLAB result . In speed vs time graph. I would like to PLOT A TANGENT LINE in
Kindly help me..

1 件のコメント

Fangjun Jiang
Fangjun Jiang 2011 年 8 月 26 日
Your question is not clear.

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

回答 (1 件)

Chaowei Chen
Chaowei Chen 2011 年 8 月 27 日

0 投票

function plot_tangent(x,y)
if nargin<2,
x=1:0.01:10;y=sin(x);
end
s=diff(y)./diff(x);
f_tangent=@(a,ind)(s(ind)*(a-x(ind))+y(ind));
x_range=[min(x) max(x)];
iscontinue=true;
plot(x,y);
[gx,gy,mouse]=ginput(1);
x_gx_diff=abs(x-gx);
ind=find(x_gx_diff==min(x_gx_diff));
hold on;
h=plot(x_range,f_tangent(x_range,ind),'r');
hold off;
iscontinue=mouse==1;
while iscontinue
[gx,gy,mouse]=ginput(1);
delete(h);
x_gx_diff=abs(x-gx);
ind=find(x_gx_diff==min(x_gx_diff));
hold on;
h=plot(x_range,f_tangent(x_range,ind),'r');
hold off;
iscontinue=mouse==1;
end

1 件のコメント

Chaowei Chen
Chaowei Chen 2011 年 8 月 27 日
you probably can work around with and integrate this code into your simulink application.

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

カテゴリ

ヘルプ センター および File ExchangeGeneral Applications についてさらに検索

タグ

質問済み:

2011 年 8 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by