Plot 3D Graph and make level curves

조회 수: 15 (최근 30일)
Bryan Ambrósio
Bryan Ambrósio 2021년 4월 22일
댓글: Star Strider 2021년 5월 1일
Hi
I have 3 vectors, where:
X is a vector of numbers;
Y is a vector of numbers;
Z is a function that depends on X and Y (i.e)
Z = 4.6597*x.^2 + 2.6897*x.*y - 0.023578*x + 8.1189*y.^2 - 1.9553*y - 1.2304;
I want to plot a 3D curve and I am not succeding. Can someone help me please? Thanks

채택된 답변

Star Strider
Star Strider 2021년 4월 23일
편집: Star Strider 2021년 4월 23일
Use the plot3 function.
If you then want it as a 2D plot, use the view function to rotate it.
EDIT — (23 Apr 2021 at 03:17)
I was intending that to use any of the q3D plotting functions, the vectors need to be transformed into matrices first, and then transformed back into vector to use plot3:
X = ...;
Y = ...;
[Xm,Ym] = ndgrid(X,Y);
Zfcn = @(x,y) 4.6597*x.^2 + 2.6897*x.*y - 0.023578*x + 8.1189*y.^2 - 1.9553*y - 1.2304;
Zm = Zfcn(Xm,Ym);
figure
plot3(Xm(:), Ym(:), Zm(:))
grid on
.
  댓글 수: 8
Bryan Ambrósio
Bryan Ambrósio 2021년 4월 30일
Thank you so much!
Star Strider
Star Strider 2021년 5월 1일
As always, my pleasure!

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

추가 답변 (2개)

Bryan Ambrósio
Bryan Ambrósio 2021년 4월 23일
I have tried plot3, but it doesnt fill my needs entirely

Bryan Ambrósio
Bryan Ambrósio 2021년 4월 23일
in plot3 z cannot be a function

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by