Please help with my function that is to read files.

function readd(txxt)
data = dlmread(txxt, '', 43, 0);
mass = data(:, 3);
temp = data(:, 2);
time = data(:, 1);
end
This is what it returns in the cmd window:
Not enough input arguments.
Error in untitled7 (line 4) data = dlmread(txxt, '', 43, 0);
I've tried setting the left hand side of the function equal to: [data] [mass,temp,time]
Nothing worked.

Antworten (1)

Star Strider
Star Strider am 20 Jul. 2016
Guessing here, but '' is an empty string. If you want to specify a space, put a space between the quotes.
See if this works:
data = dlmread(txxt, ' ', 43, 0);

2 Kommentare

pudje
pudje am 20 Jul. 2016
That part is not a problem. I can actually read the text file just fine with that original line of code. The problem is I can't seem to have it as a function.
You cannot run a function by simply clicking ‘run’. You have to use it in a command:
txxt = 'file.txt';
readd(txxt)
Of course it is not going to return anything to your workspace. To do that, you need to specify it as:
function [mass,temp,time] = readd(txxt)
then call it as:
txxt = 'file.txt';
[mass,temp,time] = readd(txxt);

Melden Sie sich an, um zu kommentieren.

Kategorien

Tags

Gefragt:

am 20 Jul. 2016

Kommentiert:

am 20 Jul. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by