Help with savefig

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with savefig

Rik-4
10/30/18

Could someone with access to Matlab run the following code?

--- Code ---
h = figure ();
sombrero
get (h, 'FileName')
savefig (h, "myfig")
get (h, 'FileName')
--- End Code ---

I'm expecting that FileName will be filled in with the name of the figure
which might be "myfig", "myfig.fig", or the full name and path to the
figure.  But this is Matlab so it might do none of these things.

Thanks,
Rik



Reply | Threaded
Open this post in threaded view
|

Re: Help with savefig

apjanke-floss
Doesn't change the value.

Per
https://www.mathworks.com/help/matlab/ref/matlab.ui.figure-properties.html,
it looks like FileName is for GUIDE's use:

--------------------------

FileName — File name
character vector | string scalar
File name for saving the figure, specified as a character vector or a
string scalar. GUIDE uses this property to store the name of the UI
layout file that it saves.

Example: figure('FileName','myfile.fig') sets the file name to myfile.fig.

--------------------------

Cheers,
Andrew

On 10/30/18 5:41 PM, Rik wrote:

> 10/30/18
>
> Could someone with access to Matlab run the following code?
>
> --- Code ---
> h = figure ();
> sombrero
> get (h, 'FileName')
> savefig (h, "myfig")
> get (h, 'FileName')
> --- End Code ---
>
> I'm expecting that FileName will be filled in with the name of the figure
> which might be "myfig", "myfig.fig", or the full name and path to the
> figure.  But this is Matlab so it might do none of these things.
>
> Thanks,
> Rik
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Help with savefig

Rik-4
In reply to this post by Rik-4
> Doesn't change the value.
Hmm, okay.  Does openfig do anything?  How about this test code:

--- Code ---
h = figure
peaks
savefig (h, 'myfig.fig')
h2 = openfig ('myfig.fig')
get (h2, 'FileName')
--- End Code ---

--Rik

Reply | Threaded
Open this post in threaded view
|

Re: Help with savefig

siko1056


On Thu, Nov 1, 2018 at 12:39 AM Rik <[hidden email]> wrote:
> Doesn't change the value.
Hmm, okay.  Does openfig do anything?  How about this test code:

--- Code ---
h = figure
peaks
savefig (h, 'myfig.fig')
h2 = openfig ('myfig.fig')
get (h2, 'FileName')
--- End Code ---

--Rik


Run with R2018b:

--- Output ---
h = 

  Figure (1) with properties:

      Number: 1
        Name: ''
       Color: [0.9400 0.9400 0.9400]
    Position: [360 198 560 420]
       Units: 'pixels'

  Show all properties

 
z =  3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ... 
   - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ... 
   - 1/3*exp(-(x+1).^2 - y.^2) 
 

h2 = 

  Figure (2) with properties:

      Number: 2
        Name: ''
       Color: [0.9400 0.9400 0.9400]
    Position: [364 191 560 420]
       Units: 'pixels'

  Show all properties


ans =

    '/home/siko1056/Downloads/myfig.fig'
--- End Output --- 

Best,
Kai