Draw an angle for two functions

1 回表示 (過去 30 日間)
Max Brückner
Max Brückner 2020 年 6 月 4 日
編集済み: Max Brückner 2020 年 6 月 5 日
Hello together,
I want to draw the angles between the X-Axis an my functions as shown in the picture.
How do I do this?
f = @(x) (tan((31.157/180) * pi) * x) - ((9.81*x.^2)/(2*25*25*(cos((31.157/180)*pi))^2));
g = @(x) (tan((62.774/180) * pi) * x) - ((9.81*x.^2)/(2*25*25*cos(((62.774/180)*pi))^2));
x = 0:0.1:60;
grid on;
hold on;
plot(x, f(x));
plot(x, g(x));

採用された回答

Takumi
Takumi 2020 年 6 月 4 日
I think there are other better ways...
f = @(x) (tan((31.157/180) * pi) * x) - ((9.81*x.^2)/(2*25*25*(cos((31.157/180)*pi))^2));
g = @(x) (tan((62.774/180) * pi) * x) - ((9.81*x.^2)/(2*25*25*cos(((62.774/180)*pi))^2));
% tangent gradient at origin
syms x
df = matlabFunction( diff(f(x)) );
dg = matlabFunction( diff(g(x)) );
alpha = atan(df(0));
beta = atan(dg(0));
x = 0:0.1:60;
plot(x, f(x));
grid on;hold on;axis equal
plot(x, g(x));
% plot(x,df(0)*x); % tangent line
% plot(x,dg(0)*x);
% circular arc
% alpha
xIntF = 5; % X-coordinate of the intersection of circle and f(x)
yIntF = f(xIntF);
rIntF = sqrt(xIntF^2+yIntF^2); % radius for alpha
theta = linspace(0,atan(yIntF/xIntF),100);
xalpha = rIntF*cos(theta);
yalpha = rIntF*sin(theta);
plot(xalpha,yalpha,'-k');
xt = 6; yt = 1; % text location
str = sprintf('\\alpha=%2.1f°',alpha*180/pi);
text(xt,yt,str)
% beta
xIntG = 6; % X-coordinate of the intersection of circle and g(x)
yIntG = g(xIntG);
rIntG = sqrt(xIntG^2+yIntG^2); % radius for beta
theta = linspace(0,atan(yIntG/xIntG),100);
xbeta = rIntG*cos(theta);
ybeta = rIntG*sin(theta);
plot(xbeta,ybeta,'-k');
xt = 13; yt = 1; % text location
str = sprintf('\\beta=%2.1f°',beta*180/pi);
text(xt,yt,str)
  1 件のコメント
Max Brückner
Max Brückner 2020 年 6 月 5 日
Thank you. That's exactly what I looked for.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by