Demo Files for "Optimizing Lookup Tables" Seminar

by

 

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

makeplot(x, optimValues, state)
function out = makeplot(x, optimValues, state)
if ~strcmp(state,'iter')
    out = 0;
    return;
end

xtry = [-3 x(1:11) 3];
ytry = [-3 x(12:22) 3];
[Xtry,Ytry] = meshgrid(xtry,ytry);
[x_fine,y_fine] = meshgrid(-3:0.05:3);
z_true = peaks(x_fine, y_fine);

clf;
F = fit([Xtry(:) Ytry(:)],peaks(Xtry(:),Ytry(:)),'linear');
Z = F(x_fine,y_fine);

pcolor(x_fine,y_fine,abs(Z-z_true).^1);
shading interp
hold all;

for n = 1:numel(xtry)
    plot(xtry(n)*[1 1], [-3 3],'k','linewidth',2,'tag','gridline');
end
for n = 1:numel(ytry)
    plot([-3 3], ytry(n)*[1 1],'k','linewidth',2,'tag','gridline');
end
caxis([0 1.3]);
ht = title(sum(abs(Z(:)-z_true(:)).^2),'Fontsize',20);
set(gca,'fontsize',16);
drawnow;
out = 0;

Contact us