Plot 3D of a function

조회 수: 3 (최근 30일)
JORGE ORDOÑEZ CARRASCO
JORGE ORDOÑEZ CARRASCO 2021년 2월 19일
댓글: JORGE ORDOÑEZ CARRASCO 2021년 2월 19일
Hello is there a short cut to plot a 3d function for example i have a linspace(0,pi) of x and linspace(0,1) of t and the a function @(x,t)=f(x,t). The way i have plotted is having x and t and loop for which calculates the values of x and t evaluated in the function:
In the image above i have created a vectors x1 and t1 of lenght=300 and evaluate them in the funcion and store them in the matrix z1. I have tried this:
But i dont think is the best way cause it takes a lot. Any suggestion.
  댓글 수: 1
JORGE ORDOÑEZ CARRASCO
JORGE ORDOÑEZ CARRASCO 2021년 2월 19일
By the way the loop for plotting took me 15 minutes and i dont think is the best way though

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

채택된 답변

Alan Stevens
Alan Stevens 2021년 2월 19일
Are you looking for something like this?
x = linspace(0,pi);
t = linspace(0,1);
z = @(x,t) 10*exp(-4*t).*sin(2*x);
[x1, t1] = meshgrid(x,t);
z1 = z(x1,t1);
surf(x1,t1,z1)
  댓글 수: 1
JORGE ORDOÑEZ CARRASCO
JORGE ORDOÑEZ CARRASCO 2021년 2월 19일
Nice I will keep it in mind but I’m gonna study your answer and get to know how works. Thank you a lot.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by