Extracting data from a matlab figure and saving it as a .mat file

69 views (last 30 days)
I have a figure that is a plot of drag torque versus rpm for 4 separate motor shafts. I would like to read the figure and extract the indicidual x (rpm) and y (drag torque) data for each motor shaft into an array that I can save as a .mat file. I have looked at using the 'findobj' function in MATLAB to look for the data related to each motor shafts x and y properties but I have not had any luck. I have attached the figure file I would like to extract the data for. Any help is greatly appreciated. Thanks

Accepted Answer

Les Beckham
Les Beckham on 3 Aug 2022
open('6000_1.fig')
hl = findobj(gca, 'Type', 'line'); % find the lines
x = get(hl, 'Xdata'); % extract the data
y = get(hl, 'Ydata');
figure
plot(x{1}, y{1}, x{2}, y{2}, x{3}, y{3}, x{4}, y{4}) % make a plot to ensure that we got the data

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!