Hi Siri, 
I gather from the code snippet that you are trying to pull the ‘label’ values from ‘fields.mat’ and use it in ‘ElectrodesDynamicTable’.  
Here is the code for doing the same: 
numShanks = 1; 
numChannelsPerShank = 8; 
% Assuming 'fields' is stored in a file named 'fields.mat' and is a cell array 
% Load 'fields' from the file 
load('fields.mat', 'fields'); % Make sure 'fields' is the correct variable name in your .mat file 
ElectrodesDynamicTable = types.hdmf_common.DynamicTable(... 
    'colnames', {'location', 'label'}, ... 
    'description', 'all electrodes'); 
Device = types.core.Device(... 
    'NeuroOmega', 'NeuroOmega', ... 
    'Alpha Omega', 'Alpha Omega' ... 
    ); 
nwb.general_devices.set('array', Device); 
for iShank = 1:numShanks 
    shankGroupName = sprintf('shank%d', iShank); 
    EGroup = types.core.ElectrodeGroup( ... 
        'description', sprintf('electrode group for %s', shankGroupName), ... 
        'location', 'GPi', ... 
        'device', types.untyped.SoftLink(Device) ... 
        ); 
    nwb.general_extracellular_ephys.set(shankGroupName, EGroup); 
    for iElectrode = 1:numChannelsPerShank 
        % Ensure 'fields' has enough entries for each electrode 
        if iElectrode <= length(fields) 
            label = fields{iElectrode}; % Access the corresponding label from 'fields' 
        else 
            label = sprintf('Electrode%d', iElectrode); % Fallback label if 'fields' is shorter than expected 
        end 
        ElectrodesDynamicTable.addRow( ... 
            'location', 'GPi', ... 
            'label', label); 
    end 
end 
ElectrodesDynamicTable.toTable() 
nwb.general_extracellular_ephys_electrodes = ElectrodesDynamicTable; 
 Here is the output of executing the above code :  

For more information on working with NWB Data, refer to the following link: 
 Hope it helps! 


