我有一個矩陣,其存儲x,y和z值,從而:Matlab的從2D彩色圖表和內插3D陣列
{x1, y1, z1},
{x2, y2, z2},
{x3, y3, z3},
etc...
我需要來內插所述數據,並繪製在一個二維曲線圖,顏色代表z值。 (example)
任何想法?
謝謝!
我有一個矩陣,其存儲x,y和z值,從而:Matlab的從2D彩色圖表和內插3D陣列
{x1, y1, z1},
{x2, y2, z2},
{x3, y3, z3},
etc...
我需要來內插所述數據,並繪製在一個二維曲線圖,顏色代表z值。 (example)
任何想法?
謝謝!
喜歡的東西griddata
可以幫助您進行插值:
x = vector(:,1);
y = vector(:,2);
z = vector(:,3);
% Settings
xres = 800; % Resolution, the higher, the smoother
yres = 800;
cm = 'default'; % Colormap
% Axes Limits
xmin = min(x);
ymin = min(y);
xmax = max(x);
ymax = max(y);
xi = linspace(xmin, xmax, xres);
yi = linspace(ymin, ymax, yres);
% Figure
myfig = figure('Position', [200 200 800 600]);
rotate3d off
[XI, YI] = meshgrid(xi, yi);
ZI = griddata(x, y, z, XI, YI, 'cubic');
mesh(XI,YI,ZI);
比你只需要它的視圖更改爲只爲z
除了一個固定值顯示某個plane
@ Alexandrew answer你可以使用更新,更快的TriScatteredInterp類而不是GRIDDATA。對於您的檢查,您可以使用2D IMAGESC而不是3D MESH。
%# insert the code from @Alexandrew answer to generate meshgrid
[XI, YI] = meshgrid(xi, yi);
TSI = TriScatteredInterp(x,y,z);
ZI = TSI(XI,YI);
imagesc(ZI)
colorbar
如果輸入矩陣是一個單元陣列,可以將其轉換爲數值矩陣a = cell2mat(a);