help-octave
[Top][All Lists]
Advanced

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

Re: How to read file and plot


From: Andy Buckle
Subject: Re: How to read file and plot
Date: Wed, 5 May 2010 10:34:33 +0100

-------------------------------------------
close all; %close any previous figures

fid=fopen("data.txt"); % TODO: check if fid is -1 and give error
line=0; %for storing the string value of each line of the file

data=zeros(2,2); %will be faster if we know how many lines are in file
%as this array will not have to be resized by octave

line_i=1;
while (-1 ~= (line=fgetl(fid)))
        data(line_i++,:)=str2num(line);
end

fclose(fid);

%displays data
data

plot(data(:,1),data(:,2))
-------------------------------------------
On Wed, May 5, 2010 at 9:22 AM, rizal <address@hidden> wrote:
>
> format file text is asci. my file is 2 coloum
> example
> 12      0.001
> 13     0.25
> 14     0.15
> .
> .
> .
>
> --
> View this message in context: 
> http://octave.1599824.n4.nabble.com/How-to-read-file-and-plot-tp2130534p2130604.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>



-- 
/* andy buckle */



reply via email to

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