How do I extract a matrix from a .txt file?
11 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Friedrich
on 22 Apr 2013
Edited: Friedrich
on 22 Apr 2013
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
0 Comments
More Answers (0)
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!