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

  • Context: MATLAB 
  • Thread starter Thread starter serialtom
  • Start date Start date
  • Tags Tags
    Data File Matlab
Click For Summary
SUMMARY

The discussion focuses on extracting data from multiple .fig files in MATLAB to plot them on a single figure. The user is advised to utilize the "hold on" command to overlay plots in one figure and "hold off" to create a new figure. Key commands include [filename,directory]=uigetfile() for file selection, open() to load the figure, and get() to retrieve the data from the axes. The process involves iterating through each .fig file to extract the X and Y data for plotting.

PREREQUISITES
  • Familiarity with MATLAB commands and syntax
  • Understanding of figure and axes manipulation in MATLAB
  • Basic knowledge of plotting functions in MATLAB
  • Experience with data extraction from graphical objects in MATLAB
NEXT STEPS
  • Explore MATLAB's hold on and hold off commands for advanced plotting techniques
  • Learn about the uigetfile() function for file selection in MATLAB
  • Investigate the get() function for accessing properties of graphical objects
  • Study MATLAB's data visualization capabilities for combining multiple datasets
USEFUL FOR

This discussion is beneficial for MATLAB users, data analysts, and engineers looking to consolidate multiple plots into a single figure for enhanced data visualization.

serialtom
Messages
1
Reaction score
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
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.
 


[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')
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K