help-octave
[Top][All Lists]
Advanced

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

Re: Plotting from txt file


From: Santiago Higuera
Subject: Re: Plotting from txt file
Date: Sun, 27 Nov 2016 11:16:17 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

Hi:

Try this:

fid = fopen('output1480196986778.txt','r');
if fid==-1
      fprintf("Error \n");
      return;
end
XX = [];
YY = [];
while ~feof(fid)
    x = fscanf(fid, '%f', 1);
    XX = [XX, x];
    fscanf(fid,'%s',2);
    y = fscanf(fid, '%f', 1);
    YY = [YY, y];
    fgets(fid);
end
fclose(fid);

plot(XX,YY);

Regards,

Santiago Higuera



El 27/11/16 a las 00:51, skematic escribió:
Dear all,

I have a text file that looks like this

2723 PID 20.00 21.56 0.00 0.00 0.00 0.00 Manual Direct
3723 PID 20.00 21.56 0.00 0.00 0.00 0.00 Manual Direct
4724 PID 20.00 21.56 0.00 0.00 0.00 0.00 Manual Direct
5725 PID 20.00 21.56 0.00 0.00 0.00 0.00 Manual Direct
6725 PID 20.00 21.56 0.00 0.00 0.00 0.00 Manual Direct
7727 PID 20.00 21.56 0.00 0.00 0.00 0.00 Manual Direct

I want to make a 2D plot with column 1 as x and column 4 as y.

I've looked up online, here is what I end up with.

filename='output1480196986778.txt';
fid = fopen(filename, 'r');
data = textscan(fid, '%s %s %s %s %s %s %s %s %s %s');
plot(data{1}, data{4});
fclose(fid);

data does get populated with the data from the txtfile but the plot function
gives this

error: plot: no data to plot
error: parse error

How can I make this plot?




--
View this message in context: 
http://octave.1599824.n4.nabble.com/Plotting-from-txt-file-tp4680792.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave





reply via email to

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