필터 지우기
필터 지우기

A smoother surfplot, maybe with pchip interpolation

조회 수: 4 (최근 30일)
Mohammed Saifuddin Ustad
Mohammed Saifuddin Ustad 2023년 5월 12일
댓글: Mathieu NOE 2023년 6월 28일
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)')

답변 (1개)

Mathieu NOE
Mathieu NOE 2023년 5월 15일
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
Mathieu NOE
Mathieu NOE 2023년 6월 28일
Hello
Problem solved ?
would you mind accepting my answer ? thanks !

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by