If you have a txt file you can use the command textscan(...) to import the file txt in a cell:
cell = textscan(fopen('file.txt'), 'options');
'cell' is the cell, 'file.txt' is the txt file name. 'options' is a string with used to define the import format ('%s' import string, '%f' import floating, ...) and the type of delimiter. All the data imported in this way are stored in the cell and to accede to the nth element of the cell you must use the brackets {} (for example cell{1} to accede to the first element).
If 'file.txt' contains the following values:
1.2 2.3
3.4 4.5
with the following code
cell = textscan(fopen('file.txt'), '%f');
var = cell{1};
in the variable 'var' are stored the numbers but it is a column vector and not a matrix/table and it must be reorderd: var = [1.2; 2.3; 3.4; 4.5].
With the following code (it is bit more complex but it does not require a prior knowledge about table dimensions to reorder the data):
cell = textscan(fopen('file.txt'), '%s', 'delimiter', '\n');
var = cell{1};
'var' is a cell array and each element contains a row of the document (thanks to the delimiter) in the string format (var{1} = '1.2 2.3', var{2} = '3.4 4.5'). If N is the length of 'var', with a for cycle from 1 to N you can accede to the various strings, convert them and store them in a matrix in this manner:
M = length(strread(var{1}, '%f')); %column number
N = length(var); %row number
a = zeros(N,M); %inizialization
for n = 1:N
a(n,:) = strread(var{n}, '%f');
end*
now 'a' is a matrix with number: a = [1.2, 2.3; 3.4, 4.5] useful for analysis and plots.