Assuming your datafile is a comma-separated text file, you can use the csvread
function in Matlab to read the data into a matrix. Then you can extract the first column of the matrix and store it as a column vector. Here's the code:
main.m48 chars3 lines
The csvread
function reads the entire file into a matrix called data
. The (:, 1)
indexing syntax extracts the first column of the matrix and stores it as a column vector called t
. You can replace 'datafile.csv'
with the name of your actual data file.
Note that this assumes that the data file has a header row. If the first row of the file also contains data, you'll need to modify the indexing to skip the header row.
gistlibby LogSnag