Effacer les filtres
Effacer les filtres

Import of multiple .fig files

1 vue (au cours des 30 derniers jours)
Georgiy
Georgiy le 19 Août 2014
Commenté : Georgiy le 19 Août 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.

Réponse acceptée

Guillaume
Guillaume le 19 Août 2014
Modifié(e) : Guillaume le 19 Août 2014
Not sure why you think open takes a format string. You're missing an sprintf:
open(sprintf('f%d.fig', n));
  1 commentaire
Georgiy
Georgiy le 19 Août 2014
Thanks! It works!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by