1

我有数据 - 3 列。第一个和第二个 - X 和 Y 坐标,第三个值。我必须使用平方插值法来拟合曲面。然后用 .jpg 背景绘制拟合输出。

我已经

[XOut, YOut, ZOut] = prepareSurfaceData(x, y, v); [c,goft]=fit([XOut,YOut],ZOut,'poly02'); plot(c);

但我不知道如何将视图更改为 XY。然后从 .jpg 文件中添加背景

请给我一些建议。

4

1 回答 1

0

所以,据我了解,这个问题与拟合无关,而是关于如何将图像放在表面上?

你说'背景',但我不确定你是指轴还是表面,但这应该可以工作(除非你需要一个额外的表面 z=0 前者):

% make dummy test data
N = 60;
X = 1:N;
Y = 1:N;
[X, Y] = meshgrid(X,Y);
Z = X - X.^2 + Y.^2 + randn(N,N)*10;

% read jpg and make same size as grid    
im = imread('yourimage.jpg');
% convert image to indexed colours    
[im, map] = rgb2ind(im, 256);

% make figure
figure(1), clf

% make image same size as grid
subimage = im(1:N,1:N);
colormap(map)

% plot surf and use image as texture
s = surf(X,Y,Z);
set(s, 'faceColor', 'texture',...
    'edgecolor', 'none',...
    'cdata', subimage)

这是你的意思吗?

于 2012-12-13T12:44:01.290 回答