How do I plot 3-dimentional graph of the following function? Can Plot3 function do this?

 채택된 답변

fun = @(x,y)100*(y-x.^2).^2 + (1-x).^2;
x = linspace(-10,10);
y = linspace(-50,-30);
plot3d(x, y, fun(x,y))

댓글 수: 3

Thanks Walter, it works, however, the graph is plotted only on a single line from (-10,-50) through (10,-30) (please see below, where I also label the axises and switch the grid on). So basically the result turns out to be a single parabola rather than a surface.
But do you know how to plot on an area of x and y axis, which is what I really want to get. And it should be like this...
Your function is defined in such a way that you can pass x and y matrices, not just vectors or scalars, into it. Because of that take a look at the MESHGRID function to generate the data points at which you evaluate and plot your function.
Thanks Steven, you're right. Also thanks to Walter.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2015년 10월 9일

댓글:

2015년 10월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by