2012-07-12 19 views
5

ich ein Zellenfeld von Struktur-Dateien erstellt habe, wie dies zum Beispiel:Zellenfeld von struct-Files

>> res2 

res2 = 

    Columns 1 through 7 

    [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] 

    Columns 8 through 10 

    [1x1 struct] [1x1 struct] [1x1 struct] 



>> res2{1} 

ans = 

    nchi005_randchi005: 0.1061 
      nfdr_randfdr: 0.0011 
      nlgt_randlgt: 2.9517e-004 
     nphast_randphast: 0.6660 
      ndd_rand_dd: 0.0020 
    ndd_rand_dd_larger: 1 

    >> res2{1}.nlgt_randlgt 

ans = 

    2.9517e-004 


>> res{:}.nlgt_randlgt 
??? Bad cell reference operation. 

Gibt es eine Möglichkeit für alle nlgt_randlgt-Bereiche res2-cellarray auf einmal zugreifen?

+1

aus meinem Verständnis auf, wie Daten in Matlab organisiert ... nein – Rasman

Antwort

5

Alles, was Sie tun müssen, ist Ihre res2 von einem Zell-Array in ein Struct-Array konvertieren (mit cell2mat). Dann können Sie die Strukturelemente genau so erreichen, wie Sie es wünschen. Hier ist ein Beispiel, wo cdat ein Zellenarray von Strukturen mit zwei Mitgliedern ist, s1 und s2.

cdat = 

    [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] 

>> dat = cell2mat(cdat) 

dat = 

1x10 struct array with fields: 
    s1 
    s2 

>> [dat(:).s1] 

ans = 

    1  1  1  1  1  1  1  1  1  1 
2

Sie können auf die Zelle zugreifen:

cellfun(@(r) r.nlgt_randlgt, res2); 
Verwandte Themen