How to plot a matrix in a 3D plot in matlab

3 vues (au cours des 30 derniers jours)
Fawaz
Fawaz le 9 Août 2023
Réponse apportée : DavidP le 9 Août 2023
I have a 3D vector which I am using to store various values. I want to take these values and plot them as points in a 3D plot, how can I do so?
  1 commentaire
the cyclist
the cyclist le 9 Août 2023
How, specifically, are the data stored? Are they in an Nx3 matrix?
Can you upload the data, or a representative sample? You can use the paper clip icon in the INSERT section of the toolbar.

Connectez-vous pour commenter.

Réponses (1)

DavidP
DavidP le 9 Août 2023
By "3D vector" I'm assuming you mean an Nx3 matrix in the form
N = 4; %Number of data points
x = [1, 2, 3, 4];
y = [2, 3, 1, 2];
z = [1, 3, 1, 4];
vect(1:N,1:3) = [x' y' z']
vect = 4×3
1 2 1 2 3 3 3 1 1 4 2 4
You can use the scatter3(x,y,z) function to plot these points as a scatter plot
scatter3(vect(:,1), vect(:,2), vect(:,3), 'bx') %vect(:,1) -> every row, first column
axis([0 5 0 5 0 5])

Catégories

En savoir plus sur Scatter 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!

Translated by