2016-05-11 12 views
1

Ich habe eine verschachtelte strucutre Array, das ich in ein großen Zellenfeld neu anordnen möge. Die sturcture sieht wie folgt aus
Umstellen verschachtelte strucutre in Zellenfeld in MATLAB

  • 1. Ebene:
    EpochedAll 1x1 strucutre
  • 2. Ebene: subject
    epoched02 1x1 strucutre
    epoched03 1x1 strucutre
    ... 1x1 strucutre
    epoched12 1x1 strucutre
  • 3. Ebene: Muskel
    ECR 1x1 st rucutre
    FCR 1x1 strucutre

  • 4. Ebene Bedingung
    grün 124x2 Doppel (Anzahl der Versuche ist für jeden Gegenstand und Zustand)
    roten Doppel
    Kontrolle 105x2 Doppel

122x2

Was ich will, bekommen, ist ein Zellenfeld, das die folgenden Spalten:
Wert von Zustand ... id von Subjekt ... id von m uscle ... id Bedingung

.
.
.

Ich bin neu in MATLAB und Programmierung im Allgemeinen und würde irgendwelche Hinweise oder Ideen zu schätzen wissen, wo

+0

Für den Start, was ist die Verbindung zwischen 'epoched ##', 'ECR/FCR',' grün/rot/kontrollierende und 'value',' id_subject', 'id_muscle',' id_cond'? Was ist der Weg zu, sagen wir, Kontrolle (15,2)? Ist es 'EpochedAll.epoched02.FCR.contol (15,2)' oder 'EpochedAll {1} ​​{1} {2} {3} (15,2)'? – Crowley

Antwort

0

beginnen So ordnet diese die auf den Muskel basierten Daten:

names = fieldnames(epochedAll); 
mus = {'ECR','FCR'}; 
cond = {'green', 'red','control'}; 
masterArray = [] 

%This program will loop through each subject and the conditions of a given 
%muscle (the muscle is chosen by writing either ECR or FCR in the ecrarray 
%variable below. It will then concatenate all of the data from each condition of 
%each patient into one master array, with numbers representing the subject 
%and condition, along with the condition values. 

for x = 1:length(names) 
    for z = 1: length(cond) 
     tempArray = [] 
     ecrarray = epochedAll.(names{x}).ECR.(cond{z})(:,1); 
     tempArray = vertcat(tempArray, ecrarray); 
     len = length(tempArray); 
     column = zeros(len, 1); 
     column(column == 0) = z; 
     condCol = column; 
     column(column == z) = x; 
     subjCol = column; 
     tempArray = horzcat(tempArray, condCol, subjCol); 
     masterArray = vertcat(masterArray, tempArray); 

    end 
end 

Hope this jemand hepls sonst

Verwandte Themen