plotting values from a file

Status
Not open for further replies.

sureka

Newbie level 5
Joined
Dec 16, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
55
i have a file in .txt format with about 1000000 values..can anyone please help me with a matlab code to plot the data between 100th value to 1000th value?
 

If You don't need to used matlab, in gnuplot 4.4 or newer it is easy with one command:
plot for [n=100:1000] 'datafile.txt' u 1:n
 
Reactions: sureka

    sureka

    Points: 2
    Helpful Answer Positive Rating
What format is the data in? Assuming it's floating point data, you can read the whole file using:
Code:
fid = fopen('filename.txt');
x = fscanf(fid,'%f');
fclose(fid);
So, to plot the data between 100th value to 1000th value, you can use something like:
Code:
fid = fopen('filename.txt');
fscanf(fid,'%f',100);
x = fscanf(fid,'%f',900);
fclose(fid);
plot(x);

To look at the different options available to you, type "help fscanf" into Matlab.
 
Reactions: sureka

    sureka

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…