help-octave
[Top][All Lists]
Advanced

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

problem with matrices operator


From: John W. Eaton
Subject: problem with matrices operator
Date: Wed, 7 Oct 2009 23:55:42 -0400

On  8-Oct-2009, febty febriani wrote:

| Hello everyone,
| 
| Maybe my case is trivial thing, but I need your thought for it,
| I have the input file like below :
| 
|  3.94979789e+06     2.07563383e+08     8.64407341e+07
|  1.99802918e+06     1.42889076e+06     5.55725247e+06
|  7.69394731e+05     1.04557613e+07     2.34593537e+06
|  2.67118351e+06     5.30308365e+06     1.46961852e+06
|  2.08552153e+06     5.29665190e+06     9.76369774e+04
| ......
| 
| The file has 2508810 rows.
| I want to do the simple matrices operator for my input file, so I  make the
| octave command like below :
| 
| ****
| fid=fopen("$dir/data-1day-1Hz/fft-${year}${month}.dat","r");
| A=fscanf(fid,"%le");
| 
| a=A(:,1);
| b=A(:,2);
| c=A(:,3);
| 
| x=c./a;
| y=c./b;
| z=c./(a.^2+b.^2);
| 
| subplot(3,1,1);plot(x);
| subplot(3,2,1);plot(y);
| subplot(3,3,1);plot(z);
| ****
| 
| But, I met some errors :
| error: invalid column index = 2
| error: evaluating assignment expression near line 4, column 2
| 
| I had no idea what problem is, because when I applied the matrices operator
| not using input file, it was OK.
| maybe, are there some problem with my command?

What does

  size (A)

tell you?  I think it will be a column vector.

If your data file contains only numbers, it will be loaded faster with
the load function, and the resulting value will have the same number
of rows and columns as the file.  Try

 A = load ("$dir/data-1day-1Hz/fft-${year}${month}.dat");

instead of fopen/fscanf.

Does your filename really have $ and { and } characters in it?

jwe


reply via email to

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