help-octave
[Top][All Lists]
Advanced

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

Re: Multi Column Data file to plot, gradient plot, or gradient of gradie


From: Joe Koski
Subject: Re: Multi Column Data file to plot, gradient plot, or gradient of gradient plot
Date: Sat, 27 Mar 2004 12:01:44 -0700
User-agent: Microsoft-Entourage/10.1.4.030702.0

on 3/26/04 11:39 AM, Timothy Milstead at address@hidden wrote:

> I have a data file with x values in one column and corresponding y values in
> the other columns of which there are one or more.
> One set of values per line.
> Values separated by comma (this can be changed if need be)
> I am completely and utterly new to octave.
> I usually learn a new package by example, I'm not very good at RTFM'ing.
> I would like to xy plot each column as a separate (coloured?) line and then
> xy plot the gradient of the data as lines and then finally the gradient of
> the gradient as xy plot.
> How on earth do I do this?
> Do I need to use octave or will gnuplot do it on its own (if so how?)
> Please be verbose and feel free to patronise (as long as it's useful to the
> goal!)
> 
As another new Octave user I faced the same problem. It turns out that
Octave and its cousin are best at reading entire matrices, so you have two
choices: Read all the data as a large matrix and then copy the columns (or
rows as appropriate) into separate variables, or resort to C-like read
statements which exist in Octave. I had pairs of x,y data in a file that I
needed to read. After some "RTFM'ing," as you suggest, I found a loop that
got the job done while checking for the end of the file. Here it is:

i=0;
fileid = fopen('647_A1.txt')
end_file = 0;
while(end_file == 0);
end_file = feof(fileid);
i++;

[t(i) x(i)] = fscanf(fileid,"%f%f","C");

end
len_x = length(x)
len_t = length(t)

This is much slower than reading a matrix and then breaking it up, but the
data end up in the correct variables (t and x). Note that the "C" I/O option
doesn't seem to be available in Matlab.

For variable numbers of columns, you may be better off reading the data as a
matrix and breaking it up. You can then use the size function to decide how
many rows and columns you have and process accordingly.

Experienced Octave users are probably cringing, but this worked for me. I
actually posted one time asking about easy ways to read multiple columns of
data, but never got a reply. OK, experts, what's the easy way to read
multiple columns?

Joe Koski


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