3D plot from excel

3 views (last 30 days)
Francesco Marchione
Francesco Marchione on 13 May 2021
Commented: Star Strider on 14 May 2021
I have a file excel with x,y coordinates and stresses for z coordinate in order to plot a 3D surface.
How can I get this surface with latex interpreter and colorbar?
I attach the excel file.
Thanks

Accepted Answer

Star Strider
Star Strider on 13 May 2021
Try something like this —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/616758/Shear%20stress%20adhesive.xlsx', 'VariableNamingRule','preserve');
% First10Rows = T1(1:10,:)
T1Sz = size(T1)
T1Sz = 1×2
69696 3
VarNames = T1.Properties.VariableNames;
N = 50; % Interpolation Matrix Size
xv = linspace(min(T1{:,1}), max(T1{:,1}), N); % Create Vector
yv = linspace(min(T1{:,2}), max(T1{:,2}), N); % Create Vector
[Xm,Ym] = ndgrid(xv,yv); % Create Interpolation Matrices
Zm = griddata(T1{:,1}, T1{:,2}, T1{:,3}, Xm, Ym); % Interpolate
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
figure
surfc(Xm, Ym, Zm)
grid on
hcb = colorbar;
hcb.TickLabelInterpreter='latex';
xlabel(VarNames{1}, 'Interpreter','latex')
ylabel(VarNames{2}, 'Interpreter','latex')
zlabel(VarNames{3}, 'Interpreter','latex')
Experiment to get different results.
.
  7 Comments
Francesco Marchione
Francesco Marchione on 14 May 2021
Thank you so much
Star Strider
Star Strider on 14 May 2021
As always, my pleasure!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!