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

๋Œ“๊ธ€ ์ˆ˜: 1

Atanas
Atanas 2023๋…„ 10์›” 1์ผ
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?

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

 ์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Star Strider
Star Strider 2023๋…„ 10์›” 1์ผ

1 ๊ฐœ ์ถ”์ฒœ

Use the scatteredInterpolant function to generate the โ€˜Zโ€™ matrix โ€”
T1 = readtable('Table Matlab surface.xlsx', 'VariableNamingRule','preserve')
T1 = 257ร—13 table
Protons Neutrons Average binding energy per nucleon Var4 Var5 Protons_1 Neutrons_1 Average binding energy per nucleon_1 Var9 Var10 Protons_2 Neutrons_2 Average binding energy per nucleon_2 _______ ________ __________________________________ ____ ____ _________ __________ ____________________________________ ____ _____ _________ __________ ____________________________________ 1 0 0 NaN NaN 3 1 1.7997 NaN NaN 1 6 0.015913 1 1 1.1116 NaN NaN 4 1 0.62156 NaN NaN 2 8 2.2574 2 1 3.0031 NaN NaN 5 1 1.0136 NaN NaN 3 9 3.0539 2 2 7.0733 NaN NaN 6 2 3.7438 NaN NaN 4 12 3.6237 3 3 5.3318 NaN NaN 7 3 4.1603 NaN NaN 5 14 4.1279 3 4 5.421 NaN NaN 8 4 5.3095 NaN NaN 6 16 4.8477 4 5 6.3185 NaN NaN 9 5 5.6045 NaN NaN 7 18 5.0225 5 5 6.4189 NaN NaN 10 6 6.4053 NaN NaN 8 20 5.3698 5 6 5.7635 NaN NaN 11 7 6.5361 NaN NaN 9 22 5.4855 6 6 7.6796 NaN NaN 12 7 6.178 NaN NaN 10 24 5.7458 6 7 7.3698 NaN NaN 13 8 6.6505 NaN NaN 11 26 5.82 7 7 7.475 NaN NaN 14 8 6.4635 NaN NaN 12 28 6.0629 7 8 7.6127 NaN NaN 15 9 6.5718 NaN NaN 13 29 6.296 8 8 7.9756 NaN NaN 16 10 6.8888 NaN NaN 14 30 6.6051 8 9 7.6741 NaN NaN 17 11 6.9244 NaN NaN 15 31 6.8114 8 10 7.6228 NaN NaN 18 12 7.1905 NaN NaN 16 33 6.9176
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

Atanas
Atanas 2023๋…„ 10์›” 1์ผ
Thank you very much for the help! Have a great day!
Star Strider
Star Strider 2023๋…„ 10์›” 1์ผ
As always, my pleasure!
You, too!

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (1๊ฐœ)

Rimisha
Rimisha 2023๋…„ 10์›” 1์ผ

0 ๊ฐœ ์ถ”์ฒœ

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

Atanas
Atanas 2023๋…„ 10์›” 1์ผ
ํŽธ์ง‘: Atanas 2023๋…„ 10์›” 1์ผ
It gives me this error
>> untitled7
Error using ()
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable
subscript, as in t(rows,vars). To select variables, use t(:,i) or for one variable t.(i). To select rows, use
t(i,:).
Error in meshgrid (line 59)
xrow = full(x(:)).'; % Make sure x is a full row vector.
Error in untitled7 (line 2)
[X,Y]=meshgrid(Protons,Neutron)
And this is the code I wrote
figure
[X,Y]=meshgrid(Protons,Neutron)
Z=reshape(AvEng,size(X))
surf(Protons,Neutron,AvEng);
I have my table divided into 3, one table for Protons with name "Protons", one for Neutrons - "Neutron" and one for Binding energy - "AvEng". Should they be divided into individual tables like that or they need to be in one big table?

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์นดํ…Œ๊ณ ๋ฆฌ

๋„์›€๋ง ์„ผํ„ฐ ๋ฐ File Exchange์—์„œ 2-D and 3-D Plots์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

์งˆ๋ฌธ:

2023๋…„ 10์›” 1์ผ

๋Œ“๊ธ€:

2023๋…„ 10์›” 1์ผ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by