Demo Files for "Optimizing Lookup Tables" Seminar

by

 

Demo Files for "Optimizing Lookup Tables" Seminar (presented at MATLAB Expo 2011)

mokuteki.m
function out = mokuteki(in)

%% 1. ŏ̃f\
clf;

[xf,yf] = meshgrid(-3 : 0.05 : 3);
zf = model(xf,yf);

h = surf(xf,yf,zf);
%% ₷邽߂Ɂc
shading interp;
lighting gouraud;
camlight;
axis vis3d;

%% 2. eObh쐬āA֐]
xbrk = [-3 in(1:11) 3];
ybrk = [-3 in(12:22) 3];

[xgrid,ygrid] = meshgrid(xbrk, ybrk);

z_table = model(xgrid,ygrid);

hold on;
hp = plot3(xgrid,ygrid,z_table,'k.');

%% 3. `ԃf쐬āAׂObhŕ]
F = fit([xgrid(:), ygrid(:)], z_table(:), 'linear');

% ׂObhŕ]
figure;
h = surf(xf ,yf , F(xf,yf));
hold on;
plot3(xgrid,ygrid,z_table,'k.');



%% 4. 덷\
figure;
ERR = abs(F(xf,yf) - zf);
surf(xf,yf,ERR);

sse = sum(ERR(:).^2);
title(sse);

out = sse;


hold on;
plot(xgrid, ygrid,'w.')
shading interp
axis tight;
colorbar;
caxis([0 1.3]);
hold on;

Contact us