Convert to three dimensional data
Afficher commentaires plus anciens
Hi guys,
I have this problem for some time which I dont know how to approach and solve. I am trying to create a three dimensional data from a two dimensional. I have data in the format:
C1 C2 C3 C4
1 2 3 10
4 6 9 20
5 4 1 10
...
and variables in C1 are 1st dimension, variables in C2 are 2nd dimension and those in C3 are 3rd dimension. C4 is the value created by three vectors in each dimension, such {1,2,3}=4. Appreciate any suggestion or thoughts.
2 commentaires
Azzi Abdelmalek
le 22 Mar 2016
Do you mean C1 , C2 and C3 are indices?
Charles Dunn
le 22 Mar 2016
Modifié(e) : Charles Dunn
le 22 Mar 2016
Not exactly sure what you're going for. Are you trying to plot this data in 3D? If so, try below, where your data should already be in a 2D array I called 'C'.
N = 10;
C = rand(N,4);
%get each variable separately
C1 = C(:,1);
C2 = C(:,2);
C3 = C(:,3);
C4 = C(:,4);
%plot data in 3D, with C4 value as the color
scatter3(C1,C2,C3,[],C4);
axis equal tight;
Or are you trying to get a 3D array from your 2D array? Unclear how you would like that to work. You might want to look at reshape(), which can reshape your array dimensions in to as many dimensions as you would like. Note that with an array, it must be an n-dimensional rectangle.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!