plotting specific data points on a cone plot.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SRINIVAS STP
el 19 de En. de 2024
Comentada: SRINIVAS STP
el 22 de En. de 2024
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 comentarios
Respuesta aceptada
Morgan
el 19 de En. de 2024
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);
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!