help-octave
[Top][All Lists]
Advanced

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

Input matrix easy question


From: John W. Eaton
Subject: Input matrix easy question
Date: Wed, 30 Jan 2008 16:39:04 -0500

On 30-Jan-2008, Oscar Bayona Candel wrote:

| 
| Hi all,
|  
| This is an easy question but I writte you because I´m not able to find the 
solution.
|  
|  
| Well I want to use an input file of data supuse matrix A which has 3 rows and 
4 colums.
|  
|  
| I define this matrix in a file like this
|  
| function [A]=EX();
|  
| A=[1 2 3 4
| 2 3 4 8
| 3 5 5 5];

The [] in the above are not necessary.
|  
| I save this information in a file.
|  
| In another file I want to call A from EX()
|  
| so I type [A]=EX();

Likewise, you don't need [] in the above statement.

| But I don´t now why it only recognise the first column¡¡¡ In facto if I pick 
size(A) it says 1,3
|  
| What I´m doing wrong?
|  
| My intention is to rest A(2,1)-A(1,2)
|  
| Thanks and sorry for this silly questions.

I can't reproduce this problem with Octave 3.0.0.

But in any case, if you just want to load numbers from a file, there
is no need to define a function to do it.  If your file (say foo.dat)
contains the lines

  1 2 3 4
  2 3 4 8
  3 5 5 5

then the Octave command

  A = load ("foo.dat");

should load the values for you.  This method should also be faster
than defining the function the way you did, though the difference
might only be noticeable for large matrices.

jwe



reply via email to

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