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 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