Is it possible to create a surface plot from scattered points?
79 次查看(过去 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!