필터 지우기
필터 지우기

plotting specific data points on a cone plot.

조회 수: 7 (최근 30일)
SRINIVAS STP
SRINIVAS STP 2024년 1월 19일
댓글: SRINIVAS STP 2024년 1월 22일
Hello,
i am programming a conex programming problem iteratively. I get global optimum solution in, say N iterations.
The solution of each iteration is to be plotted as a data point on a conic plot such that I want represent the convergence shape as a cone.
I know how to draw a 3d cone but how to add data points?

채택된 답변

Morgan
Morgan 2024년 1월 19일
If you have the x, y, and z coordinates of the data points you can use plot3
hold on
plot3(x(:),y(:),z(:),'.r','MarkerSize',12)
Doing this will give you something like this
There is lots of things you can do to dress the plot up further from there if you take a look at plot3 documentation. Here is the code I used to generate it:
% NUMBER OF POINTS
N = 100;
% GRID SIZE
Nx = 101;
Ny = 101;
% GRID AXES
xa = linspace(-1,+1,Nx);
ya = linspace(-1,+1,Ny);
% MESHGRID
[X,Y] = meshgrid(xa,ya);
% CALCULATE CONE
C = 2*sqrt(X.^2 + Y.^2);
% CALCULATE RANDOMIZED DATA POINTS
x = -1 + 2*rand([1 N]);
y = -1 + 2*rand([1 N]);
z = 2*sqrt(x.^2 + y.^2);
% SHOW CONE
surf(X,Y,C)
shading interp
axis equal tight
zlim([ 0 2 ]);
clim([ 0 2 ]);
colorbar
% ADD DATA POINTS TO PLOT
hold on
plot3(x(:),y(:),z(:),'.r','MarkerSize',12);
  댓글 수: 1
SRINIVAS STP
SRINIVAS STP 2024년 1월 22일
Thank you very much. It workedout for my problem.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by