Plot u=f(x,y,z) with all discrete data

11 ビュー (過去 30 日間)
Retam Paul
Retam Paul 2023 年 1 月 13 日
回答済み: Star Strider 2023 年 1 月 13 日
Hi all,
I have four columns of data namely cartesian coordinates (x,y,z) and a variable 'u'. All the four data are DISCRETE points. I want to create a 3D plot to visualise the contours of u using a colorbar. Can anyone help?
Thanks
Retam Paul

採用された回答

Star Strider
Star Strider 2023 年 1 月 13 日
The (x,y,z) vector data must be converted into a 2D matrix by some sort of computational magic so the contour can be plotted.
One approach —
x = randi( 9,50,1);
y = randi(49,50,1);
z = randi(99,50,1);
u = @(x,y,z) exp(-(x-mean(x)).^2) + exp(-(y-mean(y)).^2) + exp(-(z-mean(z)).^2); % Create 'u(x,y,z)'
[X,Y,Z] = ndgrid(x, y, z); % Create Matrices From The Vectors
U = mean(u(X,Y,Z),3) % Eliminate One Dimension To Create 2D MAatrix
U = 50×50
2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0824 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0013 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143 2.7143
figure
contour(U)
colormap(turbo)
colorbar
Another approach would be to plot the contours of each ‘page’ of a 3D matrix in different figures.
How you accomplish this depends on what the vectors are and what you want to do with them.
.

その他の回答 (1 件)

Davide Masiello
Davide Masiello 2023 年 1 月 13 日
編集済み: Davide Masiello 2023 年 1 月 13 日
x = rand(1,100);
y = rand(1,100);
z = rand(1,100);
u = rand(1,100);
scatter3(x,y,z,20,u,'filled')
colorbar

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by