MATLAB: Reference to non existent field

structure

I am trying to access data in structure of a file. When I try to use a variable to store the name of the structure and pass it, the compiler throws an error "Reference to non existent field". Instead of using a variable, if I write the structure name explicitly in the place of the variable, the code works. Please let me know where I am going wrong. Thanks!
Attached the code as well.
S1 = 'Dog_1_interictal_segment_0';
%S2 = 'Dog_1_preictal_segment_0';
S3 = '.mat';
for n=1:1:1
S4 = [S1 num2str(n,'%03d') S3];
Str_ic = load(S4);
%Extracting parameters
S5 = ['interictal_segment_', num2str(n)];
X = Str_ic.S5.data;
end

Best Answer

X = Str_ic.(S5).data;