How to open a saved figure?

I save figures to a MasterStruct for later access to store data, i am trying to open the figures using two different methods:
1.
figure(MasterStruct(k).fighandle)
Error using figure
Argument must be a Figure object or a positive integer.
class(MasterStruct(k).fighandle)='matlab.ui.Figure'
2.
openfig("file/subfolder/fighandle.fig")
figure(fighandle)
Error using figure
Argument must be a Figure object or a positive integer.
How can i open these previously made figures? the workspace identifies fighandle as a 1x1 figure

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 30 de En. de 2023

0 votos

If you have the figure saved in a .fig file, I think it should be
open('file/subfolder/fighandle.fig')

4 comentarios

Nicholas Kavouris
Nicholas Kavouris el 30 de En. de 2023
i have amended my ask, this was an oversight when asking my question
Does not resolve the issue
Fangjun Jiang
Fangjun Jiang el 30 de En. de 2023
Editada: Fangjun Jiang el 30 de En. de 2023
figure handle is dynamically assigned. Run below to get an idea
clear all;close all;
plot(rand(3));
savefig;close all;
a=openfig('Untitled.fig')
a =
Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [671 661 577 433] Units: 'pixels' Show all properties
b=findobj('type','Figure')
b =
Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [671 661 577 433] Units: 'pixels' Show all properties
class(a)
ans = 'matlab.ui.Figure'
class(b)
ans = 'matlab.ui.Figure'
isequal(a,b)
ans = logical
1
Nicholas Kavouris
Nicholas Kavouris el 30 de En. de 2023
i undrstand the concepts you outlined above, what I dont understand is:
When i attempt to index into the fields of the structure shown in the attached picture, why does matlab not allow me to open the figures saved in the struct?
It seems logical that using the figure() or openfig() command would work to display this figure since its class is figure
Fangjun Jiang
Fangjun Jiang el 30 de En. de 2023
The syntax for openfig(filename) is that the input argument is a .fig file name.
Use variable "a" and "b" above, "a" is a figure handle. It contains meta data of the figure. You could do
open a, it opens the figure property editor
but openfig(a) errors because openfig() expects a .fig file name.

Iniciar sesión para comentar.

Categorías

Más información sobre Printing and Saving en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de En. de 2023

Comentada:

el 30 de En. de 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by