plotting specific data points on a cone plot.
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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);
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!