Draw an angle for two functions

1 vue (au cours des 30 derniers jours)
Max Brückner
Max Brückner le 4 Juin 2020
Modifié(e) : Max Brückner le 5 Juin 2020
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));

Réponse acceptée

Takumi
Takumi le 4 Juin 2020
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 commentaire
Max Brückner
Max Brückner le 5 Juin 2020
Thank you. That's exactly what I looked for.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by