Convert to three dimensional data
古いコメントを表示
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 件のコメント
Azzi Abdelmalek
2016 年 3 月 22 日
Do you mean C1 , C2 and C3 are indices?
Charles Dunn
2016 年 3 月 22 日
編集済み: Charles Dunn
2016 年 3 月 22 日
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.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!