필터 지우기
필터 지우기

Simple interpolation inside matrix

조회 수: 1 (최근 30일)
Jakub
Jakub 2013년 12월 7일
댓글: Jakub 2013년 12월 9일
Simple question, I have matrix A=
[1 1 1 1 1]
[1 1 60 1 1]
[1 1 1 1 1]
and i want to interpolate values inside the matrix to get sometgink like
[1 15 30 15 1]
[15 30 60 30 15]
[1 15 30 15 1]
I know that i have to use interp2 but it is just not working for me...

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 12월 7일
편집: Andrei Bobrov 2013년 12월 8일
A =[ 1 1 1 1 1
1 1 60 1 1
1 1 1 1 1];
bw = A>1;
B = bwdist(bw,'cityblock');
v = [60./pow2(0:max(B(:))-1),1];
out = v(B+1);
ADD
use scatteredInterpolant:
A = [40 1 1 1 60
1 1 20 1 1
15 1 1 1 1];
[ii,jj] = find(A > 1);
ii = [ii;size(A,1)];
jj = [jj;size(A,2)];
F = scatteredInterpolant(ii,jj,[A(A>1);A(end)]);
[x,y]=ndgrid(1:size(A,1),1:size(A,2));
out = F(x,y);
  댓글 수: 5
Andrei Bobrov
Andrei Bobrov 2013년 12월 9일
see code after word ADD in my answer
Jakub
Jakub 2013년 12월 9일
Thank you very much!

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

추가 답변 (0개)

카테고리

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