Import of multiple .fig files

1 view (last 30 days)
Georgiy
Georgiy on 19 Aug 2014
Commented: Georgiy on 19 Aug 2014
Hello, I have .fig file I want to import and extract a data from it in MATLAB. This is my code:
open('f1.fig');
h = findobj(gca,'Type','line')
x=get(h,'Xdata')
y=get(h,'Ydata')
Channel_1 = y{2,1};
Channel_2 = y{3,1};
At this step, I have Channel_1 and Channel_2 arrays with data of f1.fig. All is working just fine. Here is the problem: I have multiple .fig files I want to import in order to extract data from each one of them, one by one, and combine the data together into overall arrays. I stacked at the import step. My code is:
number_of_figures = 20;
for n=1:number_of_figures
open('f%d.fig', n);
h = findobj(gca,'Type','line')
x = get(h,'Xdata')
y = get(h,'Ydata')
Channel_1 = y{2,1};
Channel_2 = y{3,1};
for i=1:2048
CH1(i+(n-1)*2048) = Channel_1(i); %combining data of all figures into CH1 array
CH2(i+(n-1)*2048) = Channel_2(i); %combining data of all figures into CH2 array
end
end
But it gives the error "Error using open. Too many input arguments." I tried %d, %s, %c - same result. Can someone tell me, how can I import these .fig files in a right way? Thanks in advance, Georgiy.

Accepted Answer

Guillaume
Guillaume on 19 Aug 2014
Edited: Guillaume on 19 Aug 2014
Not sure why you think open takes a format string. You're missing an sprintf:
open(sprintf('f%d.fig', n));

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!