+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Newbie level 5
    Points: 107, Level: 1

    Join Date
    Dec 2013
    Posts
    9
    Helped
    0 / 0
    Points
    107
    Level
    1

    plotting values from a file

    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?

    •   Alt7th January 2014, 06:05

      advertising

        
       

  2. #2
    Full Member level 2
    Points: 1,784, Level: 9

    Join Date
    Jan 2010
    Location
    Salem, Tamil Nadu, India
    Posts
    135
    Helped
    15 / 15
    Points
    1,784
    Level
    9

    Re: plotting values from a file

    try textread matlab cmd.......


    1 members found this post helpful.

    •   Alt7th January 2014, 06:22

      advertising

        
       

  3. #3
    Advanced Member level 2
    Points: 4,773, Level: 16
    Dominik Przyborowski's Avatar
    Join Date
    Jun 2013
    Location
    Poland
    Posts
    647
    Helped
    279 / 279
    Points
    4,773
    Level
    16

    Re: plotting values from a file

    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


    1 members found this post helpful.

    •   Alt7th January 2014, 09:13

      advertising

        
       

  4. #4
    Full Member level 3
    Points: 1,643, Level: 9
    Achievements:
    Created Blog entry

    Join Date
    Oct 2013
    Posts
    173
    Helped
    60 / 60
    Points
    1,643
    Level
    9
    Blog Entries
    5

    Re: plotting values from a file

    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.


    1 members found this post helpful.

--[[ ]]--