plotting specific data points on a cone plot.
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Morgan
le 19 Jan 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);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!