|
From: | marco atzeri |
Subject: | Re: Octave question: Integrating .dat files in functions? |
Date: | Tue, 13 Dec 2011 12:24:53 +0100 |
User-agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
On 12/13/2011 10:40 AM, StudentinCrisis wrote:
I've also tried this code but it doesn't work: fid = fopen('wierd.dat','r'); numInts = fscanf(fid, '%d', 1); for(i = 1: numInts) x = fscanf(fid, '%d', 1); sum = sum + x; end sum it says "error: Invalid call to sum." --
sum is a reserved word for an already existing function. So you can not use is for a variable. Try this: octave:2> mydata=dlmread("wierd.dat") mydata = 9 10 2 3 2 3 2 octave:3> sum(mydata) ans = 31 Look on "dmlread" and also "load" help to understand how to load a file in a variable. Regards Marco
[Prev in Thread] | Current Thread | [Next in Thread] |