Filter löschen
Filter löschen

A smoother surfplot, maybe with pchip interpolation

3 Ansichten (letzte 30 Tage)
Mohammed Saifuddin Ustad
Mohammed Saifuddin Ustad am 12 Mai 2023
Kommentiert: Mathieu NOE am 28 Jun. 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)')

Antworten (1)

Mathieu NOE
Mathieu NOE am 15 Mai 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 Kommentare
Mathieu NOE
Mathieu NOE am 28 Jun. 2023
Hello
Problem solved ?
would you mind accepting my answer ? thanks !

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by