Plotting a function...

I have the following function that I would like to plot.
Gamma = atand((Y)/(X));
Whats the best way to preform this task. Y and X will vary from 0 to 40.
Thanks,

 채택된 답변

Walter Roberson
Walter Roberson 2011년 2월 20일

0 개 추천

[X,Y] = meshgrid(0:.1:40, 0:.1,40);
surf(X, Y, atand(Y ./ X));

댓글 수: 8

Matt Tearle
Matt Tearle 2011년 2월 20일
Snap!
Paulo Silva
Paulo Silva 2011년 2월 20일
why not plot3 instead of surf?
Walter Roberson
Walter Roberson 2011년 2월 20일
Not plot3 because X and Y are both varying from 0 to 40, which makes this a question in which there is a Gamma defined over an area. plot3 is not suitable for drawing such things. In some cases something like a waterfall plot would be appropriate, but in such cases there are often specific graph calls.
Paulo Silva
Paulo Silva 2011년 2월 20일
Thanks Walter
Walter Roberson
Walter Roberson 2011년 2월 20일
By the way: in general, when you are working with arctan, it is better to use atan2(Y,X) rather than atan(Y./X), as atan2 gets the sector right. Unfortunately there is no atan2d (degrees), so I would recommend atan2 followed by a conversion to degrees.
Walter Roberson
Walter Roberson 2011년 2월 20일
atan2(0,0) also returns the desired 0, whereas atand(0./0) is going to return nan.
Matt Tearle
Matt Tearle 2011년 2월 20일
plot3 is for a curve in space - for each x there's one corresponding y and z, as opposed to a surface where there's a whole range of y values for each x (and vice versa)
Paulo Silva
Paulo Silva 2011년 2월 20일
thank you Walter and Matt for sharing your knowledge :)

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

추가 답변 (2개)

Matt Tearle
Matt Tearle 2011년 2월 20일

0 개 추천

[x,y] = meshgrid(0:0.5:40);
gam = atand(y./x);
surf(x,y,gam,'linestyle','none')
Mark
Mark 2011년 2월 20일

0 개 추천

Thanks for the help

카테고리

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

제품

태그

질문:

2011년 2월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by