How can I combine several file.fig together

조회 수: 9 (최근 30일)
Niloufar Baba adam
Niloufar Baba adam 2020년 3월 28일
댓글: Star Strider 2020년 3월 28일
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?

채택된 답변

Star Strider
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
Niloufar Baba adam
Niloufar Baba adam 2020년 3월 28일
I am really thankfull for your help.
Star Strider
Star Strider 2020년 3월 28일
My pleasure!
If my Answer helped you solve your problem, please Accept it!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by