title: MATLAB Set image size
body: <p>I have a code that is creating and capturing a jpg file. However, it tends to come out with two different image sizes. This becomes a problem when I want to make the jpg files into a movie. I have set <code>PaperPosition</code> and a few other things as well, but it still comes out with two image sizes. The image size change seems random since if I run the code twice, an image that had one of the sizes before could have the other size now.</p>
  
  <pre><code>nFrames = 8797; % Number of frames. Number of days between 1/1/1990 and 1/31/2014
  for k = 1:nFrames % 1/1/1990 to the number of days.
      % Map of conterminous US
      ax = figure(1);
      set(ax, 'visible', 'off', 'units','normalized','outerposition',[0 0 1 1]); %  Make window that shows up full sized, which makes saved figure clearer
      ax = usamap('conus');
      states = shaperead('usastatelo', 'UseGeoCoords', true,...
          'Selector',...
          {@(name) ~any(strcmp(name,{'Alaska','Hawaii'})), 'Name'});
      faceColors = makesymbolspec('Polygon',...
          {'INDEX', [1 numel(states)], 'FaceColor', 'none'}); % NOTE - colors are random
      geoshow(ax, states, 'DisplayType', 'polygon', ...
          'SymbolSpec', faceColors)
      framem off; gridm off; mlabel off; plabel off
  
      hold on
  
      % Plot data
      scatterm(ax,str2double(Lat_O3{k}), str2double(Lon_O3{k}), 40, str2double(data_O3{k})*1000, 'filled'); % Plot a dot at each Lat and Lon
      hold on
  
      % Colorbar
      caxis([10 90]);
      h = colorbar;
      ylabel(h,'ppb');
  
      % Title
      % date = datenum(2007, 04, 29) + k; % Convert t into serial numbers.
      title(['O3 MDA8 Concentration ', datestr(cell2mat(date_O3(k)), 'mmm dd yyyy')]); % Title changes every daytitle(str);
  
      % Capture the frame
      mov(k) = getframe(gcf); % Makes figure window pop up
  
      % Set size of image
      set(gcf,'Units','points')
      set(gcf,'PaperUnits','points')
  
      size = get(gcf,'Position');
      size = size(3:4);
      set(gcf,'PaperSize',size)
  
      set(gcf,'PaperPosition',[0,0,size(1),size(2)])
  
      % Save as jpg (just specify other format as necessary) - Must set 'facecolor' to 'none' or else color of states turn out black
      eval(['print -djpeg map_US_' datestr(cell2mat(date_O3(k)),'yyyy_mm_dd') '_O3_MDA8.jpg']);
      % saveas(gca, ['WI_' datestr(cell2mat(Date)) '_PM25.jpg']);
      clf
  
  end
  
  % Save as AVI file - Set 'facecolor' to 'white'. It looks better.
  close(gcf)
  </code></pre>
  
  <p>How can I set the image size (hopefully to full screen like I tried to do in <code>set(ax, ...)</code> so that when I save the jpg files, they are all the same size?</p>