MATLAB : how to get the data from a .fig file ?

In summary, to get data from a .fig file in MATLAB, you can use the "hold on" and "hold off" commands to plot multiple curves onto one figure. Then, you can use the "uigetfile" command to select the .fig file you want to get data from, and use the "get" command to retrieve the data from the appropriate axes and positions. Repeat this process for all .fig files you want to plot, naming each set of data accordingly.
  • #1
serialtom
1
0
MATLAB : how to get the data from a .fig file ?

Hello everybody !

I ve a problem on MATLAB : I have 5 .fig files generated and I want to plot all the curves on 1 unique .fig file can u tell me how to do or how to get the data from one .fig file ?

thanks a lot

serialtom
 
Physics news on Phys.org
  • #2
use the command "hold on" to plot all your data onto one figure area. Then "hold off" to make a new figure in a new area.
 
  • #3


[filename,directory]=uigetfile()
picture=open([directory,filename])
axs=get(gcf,'Children')
% you may have to start poking around at the different axs(n) to get the right one
pos=get(axs(2),'Children')
% same with the pos(n), especially if you labelled your plots or have more than one line
x1=get(pos(1),'Xdata')
y1=get(pos(1),'Ydata')

repeat this process for all the .fig files you have, naming each successive one x2 and y2, or whatever you choose then...

figure
hold on
plot(x1,y1,'-b')
plot(x2,y2,'-r')
...
plot(xn,yn,'-k')
 

What is MATLAB?

MATLAB is a high-level programming language and interactive environment used for numerical computation, visualization, and data analysis.

How do I open a .fig file in MATLAB?

To open a .fig file in MATLAB, you can use the "openfig" function and specify the name of the file as the input argument. Alternatively, you can use the "open" command and select the .fig file from the file browser.

How do I extract data from a .fig file in MATLAB?

To extract data from a .fig file in MATLAB, you can use the "get" function to access the properties of the figure. You can also use the "findobj" function to locate specific objects within the figure and retrieve their data.

Can I edit the data in a .fig file using MATLAB?

Yes, you can edit the data in a .fig file using MATLAB. You can use the "set" function to modify the properties of objects in the figure and update the data accordingly.

How do I save data from a .fig file in MATLAB?

To save data from a .fig file in MATLAB, you can use the "savefig" function and specify the name of the file as the input argument. This will create a new .fig file with the updated data. You can also use the "saveas" function to save the figure in a different format, such as .png or .pdf.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
959
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
992
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
818
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Back
Top