math - Bilinear interpolation in Matlab (without built in functions) -


i'm having trouble understanding how code bilinear interpolation in matlab. our assignment has using function;

b(x,y) = z_(ij) + a*(x - xj) + b*(y - yi) + c*(x - xj)(y - yi)

we're building 2 functions, 1 calculates coefficients (which i've done , passed 'check' algorithm professor) , function computes function. below code have. we're given, x,y,z,xi, , yi, while a,b,c have been computed.

my issue: function runs returns matrix when should return vector. however, return correct values in column 1, rows 1 & 2 confusing me. also, values we're given square matrix (z) , 1x2 x , y values, however, in second part of problem we're givene z = m x n matrix not square matrix code isn't working that. below current code. appreciated don't expect give me answer!

%given x = [0,1], y=[0,1], z=[0,1;2,4], = 1, b = 2, c = 1, xi = [0,.5],      yi = [0,.5]  function zi = bilinear_eval(x, y, z, a, b, c, xi, yi )     [m,n] = size(z);     j = 1:length(xi)         = length(x)         zi(i,j) = z(j,j) + a*(xi(i) - x(j)) + b*(yi(i) - y(j)) + c*(xi(i) - x(j))*(yi(i) - y(j))         end     end     end 

i don't know order of interpolation you're using, knowing lagrange polynomials or shape functions finite element analysis can helpful here.

if had function f(x, y) wanted interpolate between 4 values i'd write this:

f(x, y) = f1*n1(r, s) + f2*n2(r, s) + f3*n3(r, s) + f4*n4(r, s) 

where

-1 <= r <= 1 -1 <= s <= 1 

and

n1(r, s) = (1-r)*(1-s)/4.0 n2(r, s) = (1+r)*(1-s)/4.0 n3(r, s) = (1+r)*(1+s)/4.0 n4(r, s) = (1-r)*(1+s)/4.0 

this arrangement assumes 4 points arranged in such way f1 @ lower left, f2 @ lower right, f3 @ upper right, , f4 @ upper left in quadrilateral.

the interpolation functions range in value 0 one.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -