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

3 ビュー (過去 30 日間)
Keith Grey
Keith Grey 2020 年 6 月 8 日
回答済み: Tommy 2020 年 6 月 8 日
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 Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by