Extracting certain set of points from a 3D plot

조회 수: 30 (최근 30일)
Abdul
Abdul 2024년 3월 26일
댓글: Star Strider 2024년 4월 1일 11:02
Hi team,
I'm a novice in MATLAB. I've prepared a 3D plot using MATLAB script shown below with D1, D2 and total power values in the X, Y and Z - axes respectively.
Can a suggest a line of code or command where I give a range of power values and get a specific set of X and Y coordinate points (kinda like drawing an imaginary 3D plane in the plot and setting it at Z = some power and extracting all points that lie on that plane)? It would be really helpful.

채택된 답변

Star Strider
Star Strider 2024년 3월 26일
I would use the contour function for this.
Example —
[X,Y] = ndgrid(-3:0.1:3);
f = @(x,y) exp(-(x.^2+y.^2*3)*0.75);
Z = f(X,Y);
PowerVal = 0.41254;
figure
surf(X, Y, Z)
hold on
[c,h] = contour3(X, Y, Z, [1 1]*PowerVal, '-r', 'LineWidth',3);
hold off
colormap(turbo)
xv = c(1,2:end);
yv = c(2,2:end);
figure
plot(xv, yv)
grid
axis('equal')
axis('padded')
title("(X,Y) Coordinates At Power Value "+PowerVal)
I use contour3 here to draw the red line at the chosen level, to illustrate the idea. The contour functions only return the surface coordinates.
.
  댓글 수: 5
Abdul
Abdul 2024년 4월 1일 9:05
@Star Strider I've understood what you said. I will try implementing it. Thanks once again.
Star Strider
Star Strider 2024년 4월 1일 11:02
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by