help-octave
[Top][All Lists]
Advanced

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

Re: Formatted print


From: Andreas Helms
Subject: Re: Formatted print
Date: Fri, 26 Jul 2002 18:07:56 +0200 (MEST)

Hello,

you can use the asave function
(http://alpha0.iki.kfki.hu/~csato/octave/octave_contrib.html)
for saving ascii values to a file.

In your case it could  be done by

OUT = [T, X];
asave(OUT, 'file.dat');


Andreas


Lehrstuhl Astrophysik   mailto:address@hidden
Universitaet Potsdam    http://www.astro.physik.uni-potsdam.de/~helms
D-14469 Potsdam         ftp://ftp.astro.physik.uni-potsdam.de/pub/helms
Phone: +49 331 977 1556  FAX   : +49 331 977 1107

On Fri, 26 Jul 2002, Dorci Smith wrote:

> I'm working on a double pendulum problem to solve with a Runge-Kutta 4
> method
> in Octave.  I have been able to run the scripts and plot the results,
> but I
> would like to see the data Octave computed.  I have two variables (T,X)
> where T
> is a column vector that holds all time increments (0.00, 0.01, 0.02,
> ...) and X
> is an Nx2 matrix that holds the first and second derivatives of the y"
> equation
> being solved in the Runge-Kutta 4 script.  Octave prints the values held
> in these
> variables to the screen when I run the script, but I would like to
> output them to
> a file in the following format:
>  
> T       X
> 0.00    value  value 
> 0.01    value  value
> ...
> 100.00  value  value
> ----------------------------------------
> I have used the "disp()" function, but it returns a new line after each
> value
> it prints.  I tried using the format:
>  
> for i=0:1000
> disp(T(i), X(i,1), X(i,2));
> end
>  
> but this did not work.
> ----------------------------------------
> I originally tried to print as:
>  
> printf('%f %f\n', T, X);
>  
> but this only printed the column vector T and beneath it, the Nx2 matrix
> X
> instead of printing them side by side as shown above.
> ----------------------------------------
> I also tired:
>  
> for i=0:1000
> printf(%f %f %f\n', T(i), X(i,1), X(i,2));
> end
>  
> This never printed any values, but if I manually input a value
into the
> arrays, it
> would print the appropriate value:
>  
> code:   printf(%f %f %f\n', T(1), X(1,1), X(1,2));
> output: 0.00 value value
> ----------------------------------------
> One other format I tried was:
>  
> printf('%f %f %f\n', T(:), X(:,1), X(:,2));
>  
> however, this just printed out the T column vector as:
> 0.00   0.01  0.02
> 0.03   0.04   ...
> 99.98  99.99  100.00
>  
> After the T vector was printed, the first column of the X matrix was
> printed in
> the same format and after it was finished, the second column of the X
> matrix was
> printed.
> ----------------------------------------
> 
> My objective in formatting the output like this is to compare the
> Gnuplot
> produced by Octave with the Gnuplot created by another program.  I want
> to put
> plots on the same graph and see where they begin do differ.
>  
> I am a new Octave user and do not know the little tricks.  If anyone has
> any
> advice I would really appreciate it.
> 
> -- 
> Dorci Smith
> Co-op Tier II
> Titan Systems Corporation
> Astronautics Engineering Division
> 281/483-3365
> 
> 
> 
> -------------------------------------------------------------
> 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
> -------------------------------------------------------------
> 
> 



-------------------------------------------------------------
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]