Yes, you can extract the data from curves in MATLAB figures (.fig files) even without the original code! Since .fig files store the plotted data internally, MATLAB provides easy ways to access it programmatically. I'll cover two main methods: direct extraction (if you have MATLAB access) and digitization tools (if you only have images of the figures).
Direct Extraction from .fig Files
This pulls the exact X and Y data from the curves without any approximation.
-
Open the Figure:
matlabopenfig('your_figure.fig'); % Replace with your file name -
Get the Axes and Line Handles:
matlabax = gca; % Get current axes lines = findobj(ax, 'Type', 'line'); % Find all curve lines -
Extract Data:
matlabfor i = 1:length(lines) x_data = get(lines(i), 'XData'); % X values for curve i y_data = get(lines(i), 'YData'); % Y values for curve i % Display or save disp(['Curve ' num2str(i) ':']); disp([x_data(:), y_data(:)]); % Shows as [X Y] matrix % Optionally save to CSV writematrix([x_data(:), y_data(:)], ['curve_' num2str(i) '.csv']); end- If there are multiple curves, this loops through them.
- For subplots or other elements (e.g., error bars), use findobj with more filters like 'Tag' if set.
- No need to display the figure—run this on a closed file too!
Example output: A matrix of [X Y] pairs you can plot, analyze, or export.
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Explore similar technical troubleshooting questions and verified MATLAB solutions: