Draw an angle for two functions

1 visualización (últimos 30 días)
Max Brückner
Max Brückner el 4 de Jun. de 2020
Editada: Max Brückner el 5 de Jun. de 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));

Respuesta aceptada

Takumi
Takumi el 4 de Jun. de 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 comentario
Max Brückner
Max Brückner el 5 de Jun. de 2020
Thank you. That's exactly what I looked for.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by