How can I extract curve data from a .FIG file?

3 次查看(过去 30 天)
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.

回答(1 个)

Tommy
Tommy 2020-6-8
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

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by