I need to make a plot of this function:
f = atan((x*.8441/4)/(.8441^2-x^2))
What happens is that there is an asymptote at atan(infinity) and the values after that are negative. Is there anyway I could make the graph having atan() go from 0 to pi and instead of an asymptote have it have a value of pi/2?
Thanks.

답변 (2개)

Kevin Holst
Kevin Holst 2012년 2월 3일

1 개 추천

Not sure I'm understanding the question, are you wanting to replace any values > pi/2 with pi/2? (and any values < -pi/2 with -pi/2?)
if you're just looking to plot the function from 0 to pi, you can use the same method that I suggested on your previous question:
f = @(x) atan((x*.8441/4)/(.8441^2-x^2))
fplot(f,[0,pi])
EDIT
I think I see what you're wanting, although I couldn't open your link at work. The unwrap function is very interesting; hadn't heard of it until now, but I couldn't get it to work for this application for some reason.
There are many ways to do this, so I'll go ahead and show you one.
x = 0:0.01:2;
y = atan((x*.8441/4)./(.8441^2-x.^2));
y(y<0) = y(y<0) + pi;
plot(x,y);
note that I had to add some extra '.'s in your equation to make it work.

댓글 수: 3

Dennis
Dennis 2012년 2월 3일
Ah I probably should have pointed out more. x should go from 0 to 2 while f should have values from 0 to pi. Like this graph but having a value of 0 at negative infinity.
Dennis
Dennis 2012년 2월 3일
http://intmstat.com/analytic-trigonometry/arctanx.gif
Kevin Holst
Kevin Holst 2012년 2월 3일
See edit above.

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2012년 2월 3일

0 개 추천

See the unwrap() function to avoid having it go negative.

댓글 수: 2

Walter Roberson
Walter Roberson 2012년 2월 3일
This works (visually at least):
x = linspace(-3,3,100);
f = atan((x.*0.8441/4)./(0.8441^2-x.^2));
plot(x, unwrap(f*2)/2)
Note the use of ./ and .^ in order to process a vector of x.
Kevin Holst
Kevin Holst 2012년 2월 3일
Walter, when I plot what you posted, I get f from 0 to 2pi. Unwrap appears to be accounting for a discontinuity at -0.8 and another at 0.8, and they're cumulative. if you make your linspace from 0 to 3, it is fixed.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

질문:

2012년 2월 3일

편집:

Jan
2013년 9월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by