フィルターのクリア

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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by