필터 지우기
필터 지우기

How can I interpolate matrix?

조회 수: 3 (최근 30일)
HyoJae Lee
HyoJae Lee 2021년 3월 5일
댓글: Stephen23 2021년 3월 6일
0 0 0 0 31.2117
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
33.4177 0 33.0571 0 32.2147
I have 5*5 matrix.
I want to interpolate zeros using nonzero values.
How can I make this one?
  댓글 수: 2
Stephen23
Stephen23 2021년 3월 5일
Do you only want to interpolate, or do you want to extrapolate as well?
(If you only want interpolation, the left hand upper triangular section will be NaN)
HyoJae Lee
HyoJae Lee 2021년 3월 5일
Just interpolation.
Thanks for helping.

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

채택된 답변

Stephen23
Stephen23 2021년 3월 5일
M = [0,0,0,0,31.2117;0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;33.4177,0,33.0571,0,32.2147]
M = 5×5
0 0 0 0 31.2117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 33.4177 0 33.0571 0 32.2147
[Xi,Yi] = find(M);
[Xo,Yo] = ndgrid(1:size(M,1),1:size(M,2));
A = griddata(Xi,Yi,nonzeros(M),Xo,Yo)
A = 5×5
NaN NaN NaN NaN 31.2117 NaN NaN NaN 31.7632 31.4624 NaN NaN 32.3147 32.1344 31.7132 NaN 32.8662 32.6859 32.3851 31.9640 33.4177 33.2374 33.0571 32.6359 32.2147
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 3월 5일
편집: KALYAN ACHARJYA 2021년 3월 5일
@Stephen Cobeldick Sir, to what extent can we interpolate, is there any certain ways to measure the acceptibility of interpolated data points, because in this example available data points are very few only?
And yes you have shown in the best way, in the first section of the given data, there are no reference data points.
Thanks for your answer! This is learning for me tool. Appreciated!
Stephen23
Stephen23 2021년 3월 6일
"is there any certain ways to measure the acceptibility of interpolated data points..."
No, there is no certain way to measure the acceptability. The usefulness of interpolation (and extrapolation) depends on having sufficient prior knowledge and understanding about the underlying physical process being modelled:

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

추가 답변 (1개)

darova
darova 2021년 3월 5일
Use scatteredInterpolant

카테고리

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