problem with opening a *.fig file

  • Follow


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
0
Reply Hermano 3/12/2010 10:33:52 AM

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?
0
Reply Walter 3/12/2010 10:48:18 AM


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)
0
Reply Hermano 3/12/2010 12:45:24 PM

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?
0
Reply Walter 3/13/2010 6:42:23 AM

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
0
Reply mjavaid (3) 12/10/2012 2:35:08 PM

4 Replies
467 Views

(page loaded in 0.072 seconds)

Similiar Articles:













7/24/2012 12:17:26 AM


Reply: