MATLAB: How to plot four columns of data from a text file

data importplotplottingtext;textscan

I have an output text file of data. The first column is the time and the following are x,y,&z values for displacement and continue for almost 20,000 lines. I am trying to plot time vs displacement in x,y,&z directions and can't seem to figure out how to use 'textscan'.

Best Answer

  • Minimal code is as follows.
    f = 'somefile.txt';
    fid = fopen(f,'r');
    out = textscan(fid,'%f %f %f %f');
    out = horzcat(out{:});
    fclose(fid);