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

6 vues (au cours des 30 derniers jours)
Keith Grey
Keith Grey le 8 Juin 2020
Réponse apportée : Tommy le 8 Juin 2020
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.

Réponses (1)

Tommy
Tommy le 8 Juin 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

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by