MATLAB: Loading vectors with multiple dimensions from a .txt file

loading from .txt filevectors with multiple dimensions

I have saved vectors line by line to .txt file. Now i want to load them one by one. Problem is that, vectors have different dimensions and dimensions are unknown.
The .txt file that i'm using is similar to the testing2.txt which is generated by the following code.
A = rand(28,1);
B = rand(15,1);
C = rand(36,1);
fid=fopen('testing2.txt','w');
fprintf(fid, '%f ', A);
fprintf(fid, '\n ');
fprintf(fid, '%f ', B);
fprintf(fid, '\n ');
fprintf(fid, '%f ', C);
fprintf(fid, '\n ');
fclose(fid);
Can anyone help?? Thanks in advance.

Best Answer

Use fgetl() to read a line into a buffer. Use sscanf() to convert the line into numeric. Store in a cell array.