Is it possible to create a surface plot from scattered points?
82 ビュー (過去 30 日間)
古いコメントを表示
Good morning,
I find myself with a scatter of x and y points and would like to show them on a graph. The order of the points is random and not defined by a function. I would like to know if there is a code to turn these points into a grid so I can show my graph more clearly.
extracted from my code and current plot
position_x = Data_x
position_y = Data_y
Von_mises = Data_Von_mises
scatter(position_x, position_y, 1, Von_mises, '.')
colormap ('jet')
0 件のコメント
採用された回答
Star Strider
2022 年 7 月 6 日
Another approach —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1055560/Datas_xymises.txt', 'VariableNamingRule','preserve')
L = size(T1,1);
xv = linspace(min(T1{:,1}), max(T1{:,1}), fix(L/100));
yv = linspace(min(T1{:,2}), max(T1{:,2}), fix(L/100));
[Xm,Ym] = ndgrid(xv, yv);
Zm = griddata(T1{:,1}, T1{:,2}, T1{:,3}, Xm, Ym)
figure
surfc(Xm, Ym, Zm, 'EdgeColor','none')
colormap(turbo)
figure
surfc(Xm, Ym, Zm, 'EdgeColor','none')
colormap(turbo)
view(0,90)
.
0 件のコメント
その他の回答 (2 件)
John D'Errico
2022 年 7 月 5 日
編集済み: John D'Errico
2022 年 7 月 5 日
We don't have your data. But there are mltiple solutions you can use.
First is my gridfit. You can download it from the file exchange, for free use. The nice thing is gridfit will take only one line of code, but you would need to download it.
Next, you can use tools like scatteredInterpolant, then interpolating a grid of points through your data set. Compute the lattice of points using meshgrid, then just call scatteredInterpolant.
Again, since I lack your data, I can't show them in use here.
Chunru
2022 年 7 月 5 日
編集済み: Chunru
2022 年 7 月 5 日
a= readmatrix("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1055560/Datas_xymises.txt")
whos
position_x = a(:, 1);
position_y = a(:, 2);
Von_mises = a(:, 3);
F = scatteredInterpolant(position_x, position_y, Von_mises);
x1 = min(position_x):0.1:max(position_x);
y1 = min(position_y):0.1:max(position_y);
[xq, yq] = meshgrid(x1, y1);
zq = F(xq, yq);
imagesc(x1, y1, zq)
colormap ('jet')
figure
surf(x1, y1, zq, 'EdgeColor', 'none')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Statistics and Machine Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!