4d smooth plot with slices
6 ビュー (過去 30 日間)
古いコメントを表示
Hello I have a txt file (I have attached it as "Data.txt") with 4 columns, each representing a variable x,y,z,v. I plot this in the following manner:
load("Data.txt")
x = Data(:,1);
y = Data(:,2);
z = Data(:,3);
v = Data(:,4);
scatter3(x,y,z,40,v,'filled')
colorbar
However I would like it to be a smooth object on which I can also take vertical, horizontal or whatever slices.
5 件のコメント
Adam Danz
2021 年 1 月 20 日
Z must be a matrix. X and Y can be matricies the same size as Z or vectors that define the rows and columns of Z. V has several options but the easiest is probably a matrix the same size as Z.
Anyway, the slice function Bjorn mentioned may be better to accomplish you goal of taking slices of the object.
採用された回答
その他の回答 (1 件)
Bjorn Gustavsson
2021 年 1 月 20 日
I suggest you use the slice function for that, this type of plots is what that function was designed for.
If your Data are not on a regular grid you will have to re-interpolate it to a regular x-y-z grid. You can do that using scatteredInterpolant, see the help and documentation for how to use that.
If your data is on a regular plaid grid you simply have to reshape the data into 3-D arrays. After that is done you can slice to your hearts desires:
slice(x3d,y3d,z3d,V,[1,2,exp(1),3,pi],[0,log(2),2^.5],1+sqrt(5)/2),shading flat
HTH
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!