Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
problem with opening a *.fig file

Subject: problem with opening a *.fig file

From: Hermano Cappa

Date: 12 Mar, 2010 10:33:52

Message: 1 of 5

Hello,

I wrote a program with a GUI. I also made a button for saving the plots as a *.fig file. When I open the saved *.fig file, Matlab opens the import wizard (size= 1267x1894x3 and the class= uint8). When I click on the finish button the data is loaded in the workspace.

The figure I saved was a polar plot. What can be the problem? The size of the matrix?

Thanks

Steven

Subject: problem with opening a *.fig file

From: Walter Roberson

Date: 12 Mar, 2010 10:48:18

Message: 2 of 5

Hermano Cappa wrote:
> Hello,
>
> I wrote a program with a GUI. I also made a button for saving the plots
> as a *.fig file. When I open the saved *.fig file, Matlab opens the
> import wizard (size= 1267x1894x3 and the class= uint8). When I click on
> the finish button the data is loaded in the workspace.
> The figure I saved was a polar plot. What can be the problem? The size
> of the matrix?

Problem with the way you save the file, possibly. Could you show us the
relevant lines of code to save the plots to file?

Subject: problem with opening a *.fig file

From: Hermano Cappa

Date: 12 Mar, 2010 12:45:24

Message: 3 of 5

Walter Roberson <roberson@hushmail.com> wrote in message <hnd65i$i9e$1@canopus.cc.umanitoba.ca>...
> Hermano Cappa wrote:
> > Hello,
> >
> > I wrote a program with a GUI. I also made a button for saving the plots
> > as a *.fig file. When I open the saved *.fig file, Matlab opens the
> > import wizard (size= 1267x1894x3 and the class= uint8). When I click on
> > the finish button the data is loaded in the workspace.
> > The figure I saved was a polar plot. What can be the problem? The size
> > of the matrix?
>
> Problem with the way you save the file, possibly. Could you show us the
> relevant lines of code to save the plots to file?

function save_plot_Callback(hObject, eventdata, handles)

savePlotWithinGUI(handles.axes_for_plot);


function savePlotWithinGUI(axesObject, legendObject)
%this function takes in two arguments
%axesObject is the axes object that will be saved (required input)
%legendObject is the legend object that will be saved (optional input)

%stores savepath for the phase plot
% [filename, pathname] = uiputfile({ '*.emf','Enhanced Meta File (*.emf)';...
% '*.bmp','Bitmap (*.bmp)'; '*.fig','Figure (*.fig)'}, ...
% 'Save picture as','default');
    
[filename, pathname] = uiputfile(...
                            { '*.fig','Figure (*.fig)';...
                              '*.eps','Encapsuladed Postscript (*.eps)';...
                              '*.png','Portable Network Graphics (*.png)';...
                              '*.emf','Enhanced Meta File (*.emf)';...
                              '*.pdf','Portable Document Format (*.pdf)'}, ...
                              'Save picture as','untitled');
                             
                          
% {'*.m;*.fig;*.mat;*.mdl','MATLAB Files (*.m,*.fig,*.mat,*.mdl)';
% '*.m', 'M-files (*.m)';...
% '*.fig','Figures (*.fig)';...
% '*.mat','MAT-files (*.mat)';...
% '*.mdl','Models (*.mdl)';...
% '*.*', 'All Files (*.*)'},...
% 'Save as');



%if user cancels save command, nothing happens
if isequal(filename,0) || isequal(pathname,0)
    return
end
%create a new figure
newFig = figure;
set(newFig,'Visible','off');

%get the units and position of the axes object
axes_units = get(axesObject,'Units');
axes_pos = get(axesObject,'Position');

%copies axesObject onto new figure
axesObject2 = copyobj(axesObject,newFig);

%realign the axes object on the new figure
set(axesObject2,'Units',axes_units);
set(axesObject2,'Position',[15 5 axes_pos(3) axes_pos(4)]);

%if a legendObject was passed to this function . . .
if (exist('legendObject'))

    %get the units and position of the legend object
    legend_units = get(legendObject,'Units');
    legend_pos = get(legendObject,'Position');

    %copies the legend onto the the new figure
    legendObject2 = copyobj(legendObject,newFig);

    %realign the legend object on the new figure
    set(legendObject2,'Units',legend_units);
    set(legendObject2,'Position',[15-axes_pos(1)+legend_pos(1) 5-axes_pos(2)+legend_pos(2) legend_pos(3) legend_pos(4)] );

end

%adjusts the new figure accordingly
set(newFig,'Units',axes_units);
set(newFig,'Position',[15 5 axes_pos(3)+30 axes_pos(4)+10]);
%saves the plot
if(strcmp(filename(end-2:end),'pdf'));
    save2pdf([pathname filename],newFig,600);
else
    harm = 3;
    saveas2(newFig,[pathname filename]);
end

%closes the figure
close(newFig)

Subject: problem with opening a *.fig file

From: Walter Roberson

Date: 13 Mar, 2010 06:42:23

Message: 4 of 5

Hermano Cappa wrote:
> Walter Roberson <roberson@hushmail.com> wrote in message
> <hnd65i$i9e$1@canopus.cc.umanitoba.ca>...
>> Hermano Cappa wrote:

>> > > I wrote a program with a GUI. I also made a button for saving the
>> plots > as a *.fig file. When I open the saved *.fig file, Matlab
>> opens the > import wizard (size= 1267x1894x3 and the class= uint8).
>> When I click on > the finish button the data is loaded in the workspace.
>> > The figure I saved was a polar plot. What can be the problem? The
>> size > of the matrix?

> function save_plot_Callback(hObject, eventdata, handles)

> if(strcmp(filename(end-2:end),'pdf'));
> save2pdf([pathname filename],newFig,600);
> else
> harm = 3;
> saveas2(newFig,[pathname filename]);
> end

I do not recognize saveas2(): is it a locally written function?

Subject: problem with opening a *.fig file

From: Maria

Date: 10 Dec, 2012 14:35:08

Message: 5 of 5

Hi,
I also encountered this problem and after spending many hours found the reason. It happens when you click "save as" even though the file has .fig extension the "save as type" is Paintbrush 24-bit file (*.pcx) by default which causes the problem . I don't know how to recover the corrupted files but in future changing the save as type to MATLAB figure (*.fig) helps.

Maria Javaid
Research Assistant
Robotics Laboratory,
UIC

"Hermano Cappa" wrote in message <hnd5ag$34$1@fred.mathworks.com>...
> Hello,
>
> I wrote a program with a GUI. I also made a button for saving the plots as a *.fig file. When I open the saved *.fig file, Matlab opens the import wizard (size= 1267x1894x3 and the class= uint8). When I click on the finish button the data is loaded in the workspace.
>
> The figure I saved was a polar plot. What can be the problem? The size of the matrix?
>
> Thanks
>
> Steven

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us