MATLAB Answers

How can I plot four columns of data from a text file?

1 view (last 30 days)
Emily L
Emily L on 2 Sep 2020
Edited: Mohammad Sami on 2 Sep 2020
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'.

  0 Comments

Sign in to comment.

Accepted Answer

Mohammad Sami
Mohammad Sami on 2 Sep 2020
Edited: Mohammad Sami on 2 Sep 2020
Minimal code is as follows.
f = 'somefile.txt';
fid = fopen(f,'r');
out = textscan(fid,'%f %f %f %f');
out = horzcat(out{:});
fclose(fid);

  0 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!