clc;
close all;
clear all;

%% Structure Array

% Define Structure Array
S.time = [0 1 2 3 4 5]';
S.ch1 = [1 2 3 4 5 6]';
S.ch2 = [6 5 4 3 2 1]';

% Read Structure Array without knowing field names
names = fieldnames(S)   % get Field name from Structure Array
S.(names{1})            % = S.time
S.(names{2})            % = S.ch1

%% Table Array

% Convert Structure Array to Table
T = struct2table(S)
T.Properties

% Read Table without knowing variable names
headers = T.Properties.VariableNames
T.(headers{1})          % = T.time
T.(headers{2})          % = T.ch1