help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read values from a data file


From: Stefan Hrafn Jonsson
Subject: read values from a data file
Date: Tue, 14 Nov 2000 20:03:10 -0500 (EST)


I have a program file (the first one I wrote in octave), which I want to extend 
so it can read in number of different input values from a data file

The beginning of the program file (mslt.oct) is so (line comments added):



nor= 5;      # line 1             
noc= 4;
nn=1 
Msd =0.0013;  # line 4
Msm =0.09245;
Mmd =0.00047;
Mmw =0.00096;
Mmv =0.033;
Mwd =0.00218;
Mwm =0.06675;
Mvd =0.00122;
Mvm =0.23837;
x= [32671,57879,217.6,7400]
y= [29470,60102,240,8333];      # line 14
y2 = [y(1),y(2),y(3),y(4),sum(x)-sum(y)]
Ms = [Msd+Msm,0,0,0;-Msm,Mmd+Mmw+Mmv,-Mwm,-Mvm; 0,-Mmw,Mwd+Mwm,0; 
0,-Mmv,0,Mvd+Mvm ]
II = [1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1]
Msplusi = II + nn*Ms;
Msplusinv = inverse(Msplusi);
Msminusi = II - nn*Ms;
Spi = Msminusi * Msplusinv
.
.
.
.
.
.


The data file (ms.dat) is a text file with about 30 different sets of x, y, and 
Ms (Msd,Msm.....Mvm) 

Msd =0.00051    ; # line 1
Msm =0.10124    ;
Mmd =0.00042    ;
Mmw =0.00054    ;
Mmv =0.06814    ;
Mwd =0.00148    ;
Mwm =0.03334    ;
Mvd =0.00113    ;
Mvm =0.5128     ;
x= [89147,9032,21,578]
y= [82972,14689,42.4,1196]
# end of set one      line 12
Msd =0.00074    ;    # line 13
Msm =0.12319    ;
Mmd =0.00045    ;
Mmw =0.00075    ;
Mmv =0.07107    ;
Mwd =0.00148    ;
Mwm =0.03334    ;
Mvd =0.00113    ;
Mvm =0.5128     ;
x= [82972,14689,42.4,1196]
y= [76411,20716,63.8,1814]
#end of set 2
.
.
.
.

The question is, can I change the program such that it reads in the correct set 
depending
on a value of an index LL.


The beginning of the program would then be (with the missing statement/s in 
English replacing lines 4-14 )

nor= 5;
noc= 4;
nn=1
LL=13
read in and execute from line LL to line LL+12  of the file ms.dat in current 
directory
 and continue with the program.


Eventually I will put this in a loop and include a label in the data file.

One more thing. Am I understanding the manual correctly that double precision 
is the default in octave?



Thanks
Stefan





-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]