I understand that you want to extract data from a txt file and further save it in a struct or a matrix. There are two ways mentioned below.
The following code snippet reads the data from a txt file and save it a matrix.
fileID = fopen('data.txt','r');
formatSpec = '%d %f %d';
sizeA = [3 Inf];
A = fscanf(fileID,formatSpec,sizeA);
A = A';
The following code snippet reads the data from a txt file and save it in a struct.
[col1,col2,col3] = textread('data.txt','%d %d %d');
dataStruct = struct;
dataStruct.col1 = col1;
dataStruct.col2 = col2;
dataStruct.col3 = col3;
The following links contains more information on different format specifiers, different file formats and a few examples.