Interpolation of 3 dimensional values from a excel file

how should i interpolate them so that i can give any value of x and y in between the range to get ultimate value of z.
i have attached a file of values for more clarity.

 Risposta accettata

Read about interp2.
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/771628/excel%20table.xlsx') ;
T = table2array(T) ;
x = T(1,2:end);
y = T(2:end,1);
Z = T(2:end,2:end); % use fillmissing to fill NaNs
[X,Y] = meshgrid(x,y) ;
figure(1)
pcolor(X,Y,Z);
% do interpolation
m = 100;
xi = linspace(min(x),max(x),m) ;
yi = linspace(min(y),max(y),m);
[Xi,Yi] = meshgrid(xi,yi);
Zi = interp2(X,Y,Z,Xi,Yi);
pcolor(Xi,Yi,Zi)

6 Commenti

Thank you very much for the help. But i want the result like the image. What I've tried is not as natural as the image, but connected in a straight line
I have used pcolor. You use surf.
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/771628/excel%20table.xlsx') ;
T = table2array(T) ;
x = T(1,2:end);
y = T(2:end,1);
Z = T(2:end,2:end); % use fillmissing to fill NaNs
[X,Y] = meshgrid(x,y) ;
figure(1)
surf(X,Y,Z);
% do interpolation
m = 100;
xi = linspace(min(x),max(x),m) ;
yi = linspace(min(y),max(y),m);
[Xi,Yi] = meshgrid(xi,yi);
Zi = interp2(X,Y,Z,Xi,Yi);
surf(Xi,Yi,Zi)
shading interp
If I use surf, can I get the result like the image
I have run the code and shown it.
Thanks for your hard work

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Interpolation in Centro assistenza e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by