필터 지우기
필터 지우기

how to plot a 3d function (with two independent variables)

조회 수: 11 (최근 30일)
xueqi
xueqi 2013년 9월 20일
Hi,
I am trying to plot a 3d function,which contains two independent variables. I do not know is that I am not getting it right or something, it seems very complicated to plot it in Matlab. Could someone help me?
% d11=0.3;
d12=-0.1;
d21=0.2;
d22=-0.15;
r=0.01;
p1=0.4;
p2=0.6;
syms c1
syms c2
%eucara=@(c1,c2) -(1/r)*p1*exp(-r*(d11*c1+d12*c2))-(1/r)*p2*exp(-r*(d12*c1+d22*c2));
eucara= -(1/r)*p1*exp(-r*(d11*c1+d12*c2))-(1/r)*p2*exp(-r*(d12*c1+d22*c2));
ezplot(c1,c2,eucara)
I find that ezplot is most close to the function I want. But I get the error that there are Too many sym objects to plot. I think it means in this method, there should not be any variables in the function. So I need to write down the explicit expressions for eucara with p1,p2...etc being assigned with some particular numbers. But I do want to change them to make the plot more flexible. So my question is
  • How to plot a 3d function?
  • In which way the plot is flexible in the sense that it is easy to change the parameters of the function.

채택된 답변

A Jenkins
A Jenkins 2013년 9월 20일
ezplot() is a 2d function. ezsurf() will give you 3d.
ezsurf(char(eucara),[0 1000 0 1000])

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 9월 20일
Use matlabFunction() to transform the symbolic expression into an anonymous function. Then apply that function over a grid of points and plot the result.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by