Borrar filtros
Borrar filtros

A smoother surfplot, maybe with pchip interpolation

4 visualizaciones (últimos 30 días)
Mohammed Saifuddin Ustad
Mohammed Saifuddin Ustad el 12 de Mayo de 2023
Comentada: Mathieu NOE el 28 de Jun. de 2023
hello everyone,
I have made a surfplot using linear interpolation with x,y,z data from a csv. However i want to make the plot smoother. I have tried cubic interpolation and it does make it better. However i have heard that pchip would make it even smoother, though i have not been able to use that. So looking for a way to utilise pchip or any other interpolation method to make my surfplot smoother. and yes i am aware that increasing N would make it better, but looking for other ways.
T1 = readtable('solarcol3.csv');
VarNames = T1.Properties.VariableNames;
x = T1{:,1};
y = T1{:,2};
z = T1{:,3};
[Ux,iax,ixx] = unique(x);
[Uy,iay,ixy] = unique(y);
N = 25;
xv = linspace(min(x), max(x), N);
yv = linspace(min(y), max(y), N);
[Xm,Ym] = ndgrid(xv, yv);
Zm = griddata(x, y, z, Xm, Ym, 'cubic'); % specify cubic interpolation
figure
surfc(Xm, Ym, Zm)
colorbar
grid on
xlabel('Wind Velocity (m/s)')
ylabel('Heat Flux (W/m2)')
zlabel('Mass Flow Rate (kg/s)')

Respuestas (1)

Mathieu NOE
Mathieu NOE el 15 de Mayo de 2023
hello
I used this excellent FEX submission to get this result :
T1 = readtable('solarcol3.csv');
VarNames = T1.Properties.VariableNames;
x = T1{:,1};
y = T1{:,2};
z = T1{:,3};
[Ux,iax,ixx] = unique(x);
[Uy,iay,ixy] = unique(y);
N = 25;
xv = linspace(min(x), max(x), N);
yv = linspace(min(y), max(y), N);
[Xm,Ym] = ndgrid(xv, yv);
Zm = griddata(x, y, z, Xm, Ym, 'cubic'); % specify cubic interpolation
Zm = smoothn(Zm,1000); % Fex : https://fr.mathworks.com/matlabcentral/fileexchange/25634-smoothn?s_tid=ta_fx_results
figure
surfc(Xm, Ym, Zm)
colorbar
grid on
xlabel('Wind Velocity (m/s)')
ylabel('Heat Flux (W/m2)')
zlabel('Mass Flow Rate (kg/s)')
  11 comentarios
Mathieu NOE
Mathieu NOE el 28 de Jun. de 2023
Hello
Problem solved ?
would you mind accepting my answer ? thanks !

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by