Creating a function to read a text file

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 Kommentar

Walter Roberson
Walter Roberson am 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 15 Jul. 2016

0 Stimmen

function [mass,temp,time] = read(filex)
a = dlmread(filex);
mass = a(:, 3);
temp = a(:, 2);
time = a(:, 1);

1 Kommentar

pudje
pudje am 15 Jul. 2016
Does not work. I tried with the multiple input arguments before, too.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 15 Jul. 2016

Kommentiert:

am 15 Jul. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by