1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| function stop = optimplotfmc(x,optimValues,state,varargin)
persistent writerObj
stop = false;
switch state
case 'init'
set(gcf,'doublebuffer','on')
writerObj = VideoWriter('optimfmc.avi');
writerObj.FrameRate = 1;
open(writerObj);
case 'done'
close(writerObj);
case 'iter'
% % Reshape if x is a matrix
% x = x(:);
% xLength = length(x);
% xlabelText = sprintf('Number of variables: %g',xLength);
vx = evalin('base','vEcartHbassin');
vy = evalin('base','vAmplCycle');
x = reshape(x,numel(vy),numel(vx));
[vx,vy] = meshgrid(vx,vy);
% Display up to the first 100 values
% if length(x) > 100
% x = x(1:100);
% xlabelText = {xlabelText,sprintf('Showing only the first 100 variables')};
% end
if optimValues.iteration == 0
% The 'iter' case is called during the zeroth iteration,
% but it now has values that were empty during the 'init' case
%plotx = plot3(vx(:),vy(:),x(:),'bo');
plotx = surf(vx,vy,x,'edgecolor','r','FaceAlpha',0.66);
colormap winter
view(3)
grid on
title(sprintf('Energie = %.2f GWh',- optimValues.fval/1000),'interp','none');
zlabel(sprintf('Current point'),'interp','none');
ylabel('amplitude marée','interp','none');
xlabel('ecart bassin','interp','none');
% set(plotx,'edgecolor','none')
% set(gca,'xlim',[0,1 + xLength])
set(plotx,'Tag','optimplotfmc');
else
plotx = findobj(get(gca,'Children'),'Tag','optimplotfmc');
set(plotx,'Zdata',x);
title(sprintf('Energie = %.2f GWh',- optimValues.fval/1000),'interp','none');
end
drawnow
frame = getframe(gcf);
writeVideo(writerObj,frame);
end |
Partager