How to open multiple fig files at once through code?

%I need to open multiple files from a directory. I tried using the following code:
[figures, pathname,]=uigetfile('directory','*.fig','Multiselect','on');
for x = 1:length(figures)
Multi_Figs = figures(x).name;
Op = openfig(Multi_Figs);
end
It gave an error,
Error in Multi_Figs = figures(x).name; : Struct contents reference from a non-struct array object.
I tried removing " .name " from it and modified the code as:
[figures, pathname,]=uigetfile('directory','*.fig','Multiselect','on');
for x = 1:length(figures)
Multi_Figs = figures(x);
Op = openfig(Multi_Figs);
end
After running the code it gave another error;
Error in Op = openfig(Multi_Figs); : The value of 'Filename' is invalid. It must satisfy the function: ischar.
I converted the figure names to char by ch=char(figures) and using 'ch' in place of 'figures' in the code. But it also did not work out.
Kindly help me with opening multiple fig files at once.

답변 (1개)

KSSV
KSSV 2018년 5월 23일
편집: KSSV 2018년 5월 31일
[figures, pathname,]=uigetfile('directory','*.fig','Multiselect','on');
for x = 1:length(figures)
Multi_Figs = [pathname,filesep,figures{x}];
Op = openfig(Multi_Figs);
end

댓글 수: 5

Marine Sachel
Marine Sachel 2018년 5월 24일
편집: Marine Sachel 2018년 5월 24일
I tried using this before as well but it did not work out. It displays the error in Op = openfig(Multi_Figs); Also it says,
Error using load
Unable to read file 'filename.fig'. No such file or directory.
Even though it is displaying all figure names in the figures variable.
KSSV
KSSV 2018년 5월 24일
Are figures present in the folder?
Yes figures are present. When I run the code and it asks to select files as I have used uigetfile , I select mulitple figures from my directory and it displays all the names in the figures variable but doesn't open the figures.
Any other thing I am missing out?
KSSV
KSSV 2018년 5월 31일
Edited the code....try now....

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

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

질문:

2018년 5월 23일

댓글:

2018년 5월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by