MATLAB: How to extract a matrix from a .txt file

MATLABmatrixtxt file

Hello, I have a .txt file that looks like this, but with 38 lines in total:
1000.000000 -0.001345 -2.026022 789.652283 -0.001083 -2.025641 623.550720 -0.000872 -2.025440 492.388245 -0.000713 -2.025386
I am getting my PhD in Geophysics and this is my first semester, and I know nothing about Matlab. I would ideally like to create a color contour filled plot of the phase data, which is the second column of the above data, vs. frequency which is the first column. How do I go about doing this? I was looking at the contourf function, however I don't even know how to extract a matrix from the .txt file. Please help!
Ashley

Best Answer

Hi,
if it has really that format a dlmread should do the job:
A = dlmread('yourfile.txt',' ');
So when copy pasting your values into a txt and use dlmread I get:
>> A = dlmread('yourfile.txt',' ');
>> A
A =
1.0e+03 *
Columns 1 through 7
1.0000 -0.0000 -0.0020 0.7897 -0.0000 -0.0020 0.6236
Columns 8 through 12
-0.0000 -0.0020 0.4924 -0.0000 -0.0020