How can I combine several file.fig together
5 次查看(过去 30 天)
显示 更早的评论
I have several files which their formats are .fig (actually they are graphs), I need to combine them together for comparison.
could you please help me which function I can use?
0 个评论
采纳的回答
Star Strider
2020-3-28
编辑:Star Strider
2020-3-28
For each .fig file:
F = openfig(filename);
Lines = findobj(F, 'Type','Line');
Then, for each element of the ‘Lines’ array:
for k = 1:numel(Lines)
x{k} = Lines(k).XData;
y{k} = Lines(k).YData;
end
It obviously depends on what information are in the .fig file, however this is the usual method for recovering the data vectors or matrices from them.
You will need to do this for each .fig file, so you will need to keep the ‘x’ and ‘y’ cell arrays separate. One way is to use an outer loop to loop through the .fig files:
for k1 = 1:NumberOfFigFiles
F = openfig(filename(k1));
Lines = findobj(F, 'Type','Line');
for k2 = 1:numel(Lines)
x{k1,k2} = Lines(k2).XData;
y{k1,k2} = Lines(k2).YData;
end
end
You can then do whatever analyses or plots you want with the ‘x’ and ‘y’ cell arrays.
EDIT — (28 Mar 2020 at 15:58)
To read them and then plot them together:
FigFile{1} = '103_RU.fig';
FigFile{2} = '118_RU.fig';
for k1 = 1:numel(FigFile)
F = openfig(FigFile{k1});
Lines = findobj(F, 'Type','Line');
for k2 = 1:numel(Lines)
x{k1,k2} = Lines(k2).XData;
y{k1,k2} = Lines(k2).YData;
end
end
figure
for k1 = 1:size(x,1)
for k2 = 1:numel(x,2)
plot(x{k1,k2}, y{k1,k2})
hold on
end
end
hold off
grid
xlim([0.5 7])
ylim([0 4])
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!