# Matlab - plot from a matrix

1. May 22, 2012

### maxmilian

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

Maxmilian

2. May 23, 2012

### Pythagorean

for i=1:40
plot(A(1:56,i),A(57:112,i))
pause(.1)
end

3. May 23, 2012

### maxmilian

Thanks for your nice reply - what would I need to do if I wanted to have multiple plots in the same figure ?

4. May 23, 2012

### Pythagorean

doc subplot

OR (better)

Download subaxis from the file exchange and play with it and read the help file and documentation

5. May 23, 2012

### maxmilian

subplot is unfortunately not what I need. I need the plots to overlap eachother

6. May 23, 2012

### Pythagorean

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

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

Thn you can set their position manually:

set(ax(sprintf('%i',i),'Position',rect);

Where rect is a four element vector of the four corners. Try googlIng "axes properties"

7. May 23, 2012

### maxmilian

I resolved it by using "hold on"
But im getting a error with my function when im trying this ;

function figureplot(m)

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.

8. May 23, 2012

### Pythagorean

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?