Draw an angle for two functions

1 次查看(过去 30 天)
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by