I want to improve the mesh of my graph ?

2 views (last 30 days)
I want to increase the mesh of my graph so that it is clear and explanatory and I cannot use the interp2 function.
my code:
clear
clc
x=-(0:0.05:0.2);
y=0:0.5:2;
Z=[20.5896 20.7032 21.0404 21.5908 22.3385;21.1888 21.2992 21.6272 22.1630 22.8920;.......
21.7715 21.8790 22.1984 22.7208 23.4325;22.3391 22.4439 22.7553 23.2652 23.9607;....
22.8926 22.9948 23.2989 23.7971 24.4775];
[X,Y] = meshgrid(y,x);
surf(X,Y,Z)
title ('(d)')
xlabel('l (nm)');
ylabel('V0 (volt)');
zlabel('{\omega} (GHz)');

Accepted Answer

Mathieu NOE
Mathieu NOE on 27 Mar 2023
hello
sure you can use interp2
see example below
I opted for spline method for a smoother surface rendering
clear
clc
x=-(0:0.05:0.2);
y=0:0.5:2;
Z=[20.5896 20.7032 21.0404 21.5908 22.3385;21.1888 21.2992 21.6272 22.1630 22.8920;.......
21.7715 21.8790 22.1984 22.7208 23.4325;22.3391 22.4439 22.7553 23.2652 23.9607;....
22.8926 22.9948 23.2989 23.7971 24.4775];
[X,Y] = meshgrid(y,x);
figure(1),
subplot(2,1,1),surf(X,Y,Z)
title ('(d)')
xlabel('l (nm)');
ylabel('V0 (volt)');
zlabel('{\omega} (GHz)')
% refined mesh plot
N = 10; % upsampling factor
dx = mean(diff(x));
xi=x(1):dx/N:x(end);
dy = mean(diff(y));
xi=x(1):dx/N:x(end);
yi=y(1):dy/N:y(end);
[Xi,Yi] = meshgrid(yi,xi);
Zi = interp2(X,Y,Z,Xi,Yi,'spline');
subplot(2,1,2),
surf(Xi,Yi,Zi)
title ('(d)')
xlabel('l (nm)');
ylabel('V0 (volt)');
zlabel('{\omega} (GHz)');
  2 Comments
merwan behar
merwan behar on 27 Mar 2023
Thank you very much, you are very professional
Mathieu NOE
Mathieu NOE on 28 Mar 2023
my pleasure !
do you mind accepting my answer ? thanks

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!