Plotting a 3D matrix with plot3
显示 更早的评论
I have 3 Matrices .
P = rand (2,2,3) ; % row=2, col =2, slice (z axis) =3
Q = rand (1,2);
R = rand (1,2);
I want to plot the Matrix P with corresonponding to Q and R matrix in such a way that :
In 3 dimensional plot => X axis : Q Matrix ; Y axis : R Matrix ; Z axis =P Matrix.
Thank you for your kind help !
6 个评论
Walter Roberson
2022-9-21
Your X axis, Q, is 2 elements long. Your Y axis, R, is 2 elements long. Your Z axis, P, is 2 x 2 x 3.
We could guess that you might want each combination of element of Q with each element of R to define 2 x 2, but that leaves you with 3 values for each location, and you have not defined a meaning for that. For example is it 3 independent 2 x 2 surfaces?
Amit Chakraborty
2022-9-21
You have three values for each location. How would you like the plot for that to be represented?
For example do you want the first value to be converted into Red component, the second value to be converted into Green component, and the third value to be converted into Blue component of a face?
P = rand (2,2,3) ; % row=2, col =2, slice (z axis) =3
Q = rand (1,2);
R = rand (1,2);
[Qg, Rg] = ndgrid(Q, R);
dotsize = 100;
scatter(Qg(:), Rg(:), dotsize, reshape(P, [], 3), 'filled' )
Bjorn Gustavsson
2022-9-21
With so few points to plot scatter3 might be the most straight-forward way to present this result. In addition to direct conversion to RGB-tripplets one could also consider using size for one of the components and use some combination of hue saturation and intensity/value for the other two. Exactly what is best for your data depends entirely on what P is.
Amit Chakraborty
2022-9-22
编辑:Amit Chakraborty
2022-9-22
Walter Roberson
2022-9-22
See slice
回答(1 个)
LambdaL = linspace(0.000001,0.0001,20); % [Matrix in X axis]
LambdaT = linspace(0.000001,0.0001,20); % [Matrix in Y axis]
z = [1 2 3 4 5]; % [Matrix in Z axis]
[LL,LT,Z] = meshgrid(LambdaL,LambdaT,z) ;
P = rand(20,20,5) ;
% plot plane at x = .000001
slice(LL,LT,Z,P,LambdaL(1),[],[])
% plot plane at x = .000001 and y = 0.0001
slice(LL,LT,Z,P,LambdaL(1),LambdaT(end),[])
% plot all planes along x
slice(LL,LT,Z,P,LambdaL,[],[])
1 个评论
Bjorn Gustavsson
2022-9-22
Sometimes I have had success with manipulating the "alpha" properties of the surfaces slice generates:
phSl = slice(LL,LT,Z,P,LambdaL,[],[]);
set(phSl,'FaceAlpha',0.7)
shading flat
If that type of visualization is what you're after matlab is a bit lacking, and the best software I've encountered is vis5d - which is an open software project that does this type of volume renderings, primarily for weather-data.
类别
在 帮助中心 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



