Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab - plot from a matrix

  1. May 22, 2012 #1
    Hi all

    I am novice matlab programmer, and I need alittle help with plotting points, given in a txt. file.

    I have a text file containing 56 points for 40 pictures. Ive loaded the txt file by "load -ASCII nameofthefile.TXT" - and thereby created a matrix <112x40 double> the first 56 rows are x and rows from 57 to 112 are the y. My question is how do I plot each of these 40 pictures each containing the 56 points ?

    kind regards

  2. jcsd
  3. May 23, 2012 #2


    User Avatar
    Gold Member

    for i=1:40
  4. May 23, 2012 #3
    Thanks for your nice reply - what would I need to do if I wanted to have multiple plots in the same figure ?
  5. May 23, 2012 #4


    User Avatar
    Gold Member

    doc subplot

    OR (better)

    Download subaxis from the file exchange and play with it and read the help file and documentation
  6. May 23, 2012 #5
    subplot is unfortunately not what I need. I need the plots to overlap eachother
  7. May 23, 2012 #6


    User Avatar
    Gold Member

    You'll have to call the axes by handle then:

    ax.(sprintf('%i',i)) = axes;

    Thn you can set their position manually:


    Where rect is a four element vector of the four corners. Try googlIng "axes properties"
  8. May 23, 2012 #7
    I resolved it by using "hold on"
    But im getting a error with my function when im trying this ;

    function figureplot(m)
    load -ascii shapes.txt

    for i=1:m

    ??? Input argument "m" is undefined.

    What im trying to do, is making a function where I can tell it how many plots I want in a single figure. So by calling figureplot(5) - it would plot 5 plots in a figure.
  9. May 23, 2012 #8


    User Avatar
    Gold Member

    Oh! you wanted them to overlap all in the same place...? Why don't you just plot them all at once?

    I don't see a problem with what you've posted. I usually don't use the -ascii flag and haven't had problems, but maybe it's something you do elsewhere in your code?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook