Another question I would like to aks is if there is a way find a suitable 3D function from the surface model or I need to do something else to find the 3D function that would suit this surface?
How do I make a 3D surface from table data?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Atanas
el 1 de Oct. de 2023
Comentada: Star Strider
el 1 de Oct. de 2023
Hello,
I have been struggling to create this 3D mesh and I hope someone can help me. I need to get the data from "Protons" on the X axis, the data from "Neutrons" on the Y axis and "Average binding energy" on the Z axis. I am new to Matlab and don't really understand how the code works, I have difficulties finding a way to put all the information in a form of x=[]; y=[]; z=[];. I figured there should be another way to use the data from the table but I have no clue how to do it.
Thank you in advance!
Atanas
Respuesta aceptada
Star Strider
el 1 de Oct. de 2023
T1 = readtable('Table Matlab surface.xlsx', 'VariableNamingRule','preserve')
VN = T1.Properties.VariableNames;
Protons = T1.(VN{1});
Neutrons = T1.(VN{2});
BindingEnergy = T1.(VN{3});
N = 100;
pv = linspace(min(Protons), max(Protons), N);
nv = linspace(min(Neutrons), max(Neutrons), N);
[Pm,Nm] = ndgrid(pv, nv);
BE = scatteredInterpolant(Protons, Neutrons, BindingEnergy);
BEm = BE(Pm,Nm);
figure
surfc(Pm, Nm, BEm)
colormap(turbo)
colorbar
xlabel(VN{1})
ylabel(VN{2})
zlabel(VN{3})
.
2 comentarios
Más respuestas (1)
Rimisha
el 1 de Oct. de 2023
To create a 3D surface from table data in MATLAB, you can use the meshgrid function to generate coordinate matrices for the X and Y axes, and then use the surf function to plot the surface. Here's an example:
Matlab
% Assuming you have the data stored in variables protons, neutrons, and binding_energy
% Create coordinate matrices
[X, Y] = meshgrid(protons, neutrons);
% Reshape binding_energy into a matrix of the same size as X and Y
Z = reshape(binding_energy, size(X));
% Plot the surface
surf(X, Y, Z);
Regarding finding a suitable 3D function for the surface, it depends on the characteristics of your data. If you have prior knowledge or a theoretical model that suggests a specific function, you can fit the data to that function using curve fitting techniques. Otherwise, you can use interpolation methods to estimate values between data points.😊
1 comentario
Ver también
Categorías
Más información sobre Language Fundamentals 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!
