store the first column of input.dat in a vector x in matlab

You can use the importdata function to read the data from the input file and then store the first column (assuming it is a column vector) in the variable x using the (:,1) notation. Here's an example code snippet:

main.m
data = importdata('input.dat');
x = data(:,1);
47 chars
3 lines

Note that if the input file contains column headers, you should use the textdata output of importdata to store them.

related categories

gistlibby LogSnag