Is it possible to create a surface plot from scattered points?
82 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Reto Kurz
el 5 de Jul. de 2022
Respondida: Star Strider
el 6 de Jul. de 2022
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 comentarios
Respuesta aceptada
Star Strider
el 6 de Jul. de 2022
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 comentarios
Más respuestas (2)
John D'Errico
el 5 de Jul. de 2022
Editada: John D'Errico
el 5 de Jul. de 2022
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
el 5 de Jul. de 2022
Editada: Chunru
el 5 de Jul. de 2022
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 comentarios
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!