Path: news.mathworks.com!not-for-mail
From: "Nathan " <nathan.hamilton@uah.edu>
Newsgroups: comp.soft-sys.matlab
Subject: .fig not saved properly using "saveas"
Date: Fri, 5 Apr 2013 20:30:13 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 11
Message-ID: <kjnc8k$48b$1@newscl01ah.mathworks.com>
Reply-To: "Nathan " <nathan.hamilton@uah.edu>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1365193813 4363 172.30.248.38 (5 Apr 2013 20:30:13 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 5 Apr 2013 20:30:13 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 4210197
Xref: news.mathworks.com comp.soft-sys.matlab:792786

In the following section of code, I am attempting to save a plot (a figure within a custom GUI) as a ".fig" file. The file seems to save properly, but when I open the ".fig" file in MATLAB, it only appears as graphic. That is, the image is pixelated and the plot's data is not accessible using MATLAB's figure tools. For example, the Data Cursor selects pixel values rather than data points along the curve.

The applicable code section:

saveFolder = uigetdir(savePath);
F=getframe(handles.axes1); %select axes in GUI
figure(); %new figure
fileTitle = saveFileName; %filename
image(F.cdata); %show selected axes in new figure
saveas(gcf, fullfile(saveFolder,fileTitle),'fig'); %save figure
close(gcf); %and close it