How to plot 3D surface using excel data

4 views (last 30 days)
I am having 3 columns of data points x,y,x in the attached excel sheet. I want to plot a 3d surface plot but not able to get it. I can plot scatter and line plot in 3d but have no idea about the surface plot. Please help me. Thank you.

Accepted Answer

DGM
DGM on 3 May 2021
Edited: DGM on 3 May 2021
You can just use griddata()
A = [7.41162174 6.61953159 270.85708135;
270.85708135 4.14570206 150.27856724;
3.49277506 4.12808488 4.12808488;
2.54891011 6.07149732 176.00967373;
6.13071965 6.18031922 240.13805102;
7.08283179 6.62808728 263.96539018;
6.2104966 6.13536532 240.99927245;
8.52135678 7.30461006 301.01564623;
7.9649927 7.36886302 291.15927526;
3.27410113 4.47719015 164.98276167;
6.74648475 8.36099545 281.80119594;
3.40703626 4.46775864 166.99132853;
7.69095859 4.16382224 241.04512095;
5.07122134 5.418464 209.4760486;
9.58511858 7.78269843 329.72669642;
4.39638102 5.35819071 196.4747204;
2.78186323 6.71728575 189.12573383;
3.30798532 6.23281663 189.81922088;
2.56131647 8.17237926 205.47389994;
2.87943383 8.31261541 211.85807259;
2.96723309 4.28802313 157.61614882;
2.92430753 4.62904925 161.60606567;
2.67234201 4.25550244 152.82722365;
2.52224898 6.16973031 177.00686752;
8.50795219 7.63480331 305.60913422;
2.51838717 5.99854218 174.5849316;
6.408319 7.03916466 257.06492586;
2.51774773 6.0681463 175.54513027;
5.6276336 5.01110358 213.67399376;
8.63008325 9.81218517 338.73937966;
2.51746164 6.16376666 176.86277098;
4.12621319 10.57894271 264.41133037;
2.51185567 6.70950116 184.3492229;
2.51544904 6.31835977 179.01080891;
2.50998891 8.66138927 211.24359949;
3.6910239 5.79080919 189.89428233;
2.51223388 6.66833275 183.91484513;
3.0388779 6.22879138 185.3936984;
2.51394062 7.32302153 192.81551593;
4.120407 10.63242361 265.11202253;
2.50125708 4.14648832 148.98397521;
2.50037394 4.04357588 147.5662626;
2.50015549 6.3549237 179.28030936];
% this is scattered data
ax = A(:,1);
ay = A(:,2);
az = A(:,3);
% create a grid basis and then interpolate on the grid
n = 40;
x = linspace(min(ax),max(ax),n);
y = linspace(min(ay),max(ay),n);
Z = griddata(ax',ay,az,x',y);
% plot it
surf(x',y,Z)
xlabel('x')
ylabel('y')
  1 Comment
raina RAJ
raina RAJ on 3 May 2021
In the x-axis the limit seems till 200...but in my x data the limit is till 10 scale. How to do that.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!