Interpolation curve to the surface

This is the interpolation problem: I have a function z = z (x, y), and I know the relationship between x and y, as x = f (y, x_0). Here x_0 are the initial points of the curves in time y = 0. Suppose that x_0 = [0 1 2] has three values. For each value x_0, I get a curve in R ^ 2.x1 = f1 (y), x2 = f2 (y) and x3 = f3 (y), and I draw the curves z1, z2, z3 in R ^ 3 using (x1 , f1), (x2, f2) and (x3, f3). How can I interpolate z1, z2.23 to get the surface? I would be grateful for any help, mgr

+1
source share
1 answer

Using your notation and some arbitrary relationship examples for x = f (x0, y) and z = f (x, y), this is how you do it (I also added a direct calculation graph for reference)

% Define grid x0_orig = 0:2; y_orig = 0:3; [x0, y] = meshgrid(x0_orig, y_orig); % Calculate x (replace the relationship with your own) x = x0 + 0.1 * y.^2; % Calculate z (replace the relationship with your own) z = 0.1 * (x.^2 + y.^2); % Plot subplot(1,3,1) surf(x, y, z) xlabel('x') ylabel('y') zlabel('z') title('Original data') %%%%%%%%%% % Interpolate with finer grid x0i = 0:0.25:2; yi = 0:0.25:3; xi = interp2(x0_orig, y_orig, x, x0i, yi'); [x0i yi] = meshgrid(x0i, yi); zi = interp2(x0, y, z, x0i, yi); subplot(1,3,2) surf(xi, yi, zi); title('Interpolated data') %%%%%%%%%% % Recalculate directly with finer grid x0i = 0:0.25:2; yi = 0:0.25:3; [x0i yi] = meshgrid(x0i, yi); xi = x0i + 0.1 * yi.^2; zi = 0.1 * (xi.^2 + yi.^2); subplot(1,3,3) surf(xi, yi, zi) title('Recalculated directly') 

enter image description here

0
source

Source: https://habr.com/ru/post/1502593/


All Articles