필터 지우기
필터 지우기

Interpolation for x,y,z values

조회 수: 13 (최근 30일)
Prasad Joshi
Prasad Joshi 2022년 7월 29일
댓글: Star Strider 2022년 7월 29일
I am doing interpolation of z using x & y values ..But I am getting NAN values using interpolation how can I removed this NAN and interpolate it to gives actual Value.. I am herewith attaching my Excel file, code and error
clear all
close all
clc
a=xlsread('Book2.xlsx')
x = a(:,1);
y =a(:,2);
z = a(:,3);
xq=[800 1000 1250 1500 1750 2100 2500 3000 3500 4000 4500 5000 5500 6000 6500];
yq=(100:100:2700)'
vq = griddata(x,y,z,xq,yq)
mesh(xq,yq,vq)
hold on
plot3(x,y,z,'o')

채택된 답변

Star Strider
Star Strider 2022년 7월 29일
The data in the file do not appear to resemble the data in the image.
For those, the fillmissing function (R2016b and later releases) is likely the best option, however it will be necessary for you to experiment to get the desired result—
a = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1081705/Book2.xlsx', 'VariableNamingRule','preserve')
a = 37×3 table
N PCOL TAPE (iso) ______ ______ __________ 799.94 660 30.28 800.01 359.9 37.21 800.08 1011.3 28.63 1250 660 48.64 1250 1552.3 28.76 1250 360 52.57 1250.2 1020 28.19 1749.9 359.9 47.8 1750 1020.3 26.61 1750 2234 30.51 1750.1 660 48.77 2499 839.9 28.27 2499.7 2317.7 31.83 2500.7 360 35.03 2500.9 2312.7 31.92 2501.1 1020.2 26.76
a(:,1:3) = fillmissing(a(:,1:3), 'makima', 'EndValues','extrap') % Experiment With The 'method' (Here: 'makima'), The 'EndValues' extrapolation use the same 'method'
x = a{:,1};
y = a{:,2};
z = a{:,3};
L = size(a,1);
xq = linspace(min(x), max(x), L);
yq = linspace(min(y), max(y), L);
[X,Y] = ndgrid(xq, yq);
Z = griddata(x, y, z, X, Y);
figure
surfc(X, Y, Z)
grid on
.
  댓글 수: 6
Prasad Joshi
Prasad Joshi 2022년 7월 29일
Thanks
Star Strider
Star Strider 2022년 7월 29일
As always, my pleasure!

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

추가 답변 (1개)

Mathias Smeets
Mathias Smeets 2022년 7월 29일
You are getting NaN points because some query points (for example your lowest y-values) are outside your actual data. It is not possible to extrapolate with the griddata function. Look this link for more information.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by