How can I extract curve data from a .FIG file?
3 views (last 30 days)
Show older comments
I have 10 .FIG files plotted using the segment below.
yyaxis left
plot(50:450, V1 * 10^6, 'r')
xlabel('Frequency (Hz)')
ylabel('S')
yyaxis right
plot(50:450, V2 * 10^6, '--r')
ylim([0 10])
ylabel('SS')
xlim([50 250])
ax = gca;
ax.YAxis(1).Color = 'k';
ax.YAxis(2).Color = 'k';
I want to take the **first curve from each figure & plot them on one figure.
% **The first curve is the yyaxis left portion (from above).
plot(50:450, V1 * 10^6, 'r')
xlabel('Frequency (Hz)')
ylabel('S')
Is there a way I can accomplish that? If so, could you outline the method or point me in the right direction with the documentation?
Thank you.
0 Comments
Answers (1)
Tommy
on 8 Jun 2020
You could use findobj() on each figure to find the handles of the two lines. You can differentiate the lines by their LineStyles (maybe there's a better way to distinguish the two lines, but I couldn't come up with it). All together, something like this:
% for final product:
f = figure; ax = axes(f, 'NextPlot', 'add');
filenames = {'file1.fig', 'file2.fig', ..};
for i = 1:numel(filenames)
f1 = openfig(filenames{i}); % load the old figure
lh = findobj(f1, 'Type', 'Line', 'LineStyle', '-'); % find the line with '-' linestyle
copyobj(lh, ax); % copy that line to your new axes
delete(f1); % delete the old figure
end
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!