Creating a function to read a text file

2 views (last 30 days)
pudje
pudje on 15 Jul 2016
Commented: Walter Roberson on 15 Jul 2016
What is wrong with this code? I just want to parse a text file, and sort it into desperate arrays.
function [mass] = read(filex)
a = dlmread(filex);
mass = a(:, 3);
temp = a(:, 2);
time = a(:, 1);
end
  1 Comment
Walter Roberson
Walter Roberson on 15 Jul 2016
You do not indicate what problem you are encountering.
Your code should do something useful if you pass it a string which is the name of a text file that has no headers and which is comma or tab delimited.

Sign in to comment.

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 15 Jul 2016
function [mass,temp,time] = read(filex)
a = dlmread(filex);
mass = a(:, 3);
temp = a(:, 2);
time = a(:, 1);
  1 Comment
pudje
pudje on 15 Jul 2016
Does not work. I tried with the multiple input arguments before, too.

Sign in to comment.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!