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')
source share