Plotting Multiple Pictures with Points from a Matrix in MATLAB

  • Context: MATLAB 
  • Thread starter Thread starter maxmilian
  • Start date Start date
  • Tags Tags
    Matlab Matrix Plot
Click For Summary

Discussion Overview

The discussion revolves around plotting multiple pictures with points from a matrix in MATLAB. Participants explore methods for visualizing data points loaded from a text file, focusing on how to display multiple plots either separately or overlapping within the same figure.

Discussion Character

  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • Maxmilian seeks assistance with plotting 56 points for 40 pictures using a matrix created from a text file.
  • One participant suggests a basic loop for plotting each picture individually using the plot function.
  • Maxmilian inquires about plotting multiple images in the same figure.
  • Another participant recommends using the subplot function or an alternative called subaxis for better control over plot layout.
  • Maxmilian expresses that subplot does not meet their needs as they want overlapping plots.
  • A participant advises using axes handles to manually set positions for overlapping plots.
  • Maxmilian mentions an error encountered while trying to create a function for plotting a specified number of plots in a single figure.
  • Another participant suggests plotting all points at once to achieve the desired overlapping effect, questioning the necessity of the -ascii flag in the loading process.

Areas of Agreement / Disagreement

Participants have differing views on the best method to achieve overlapping plots, with some advocating for using axes properties while others suggest plotting all points simultaneously. The discussion remains unresolved regarding the optimal approach.

Contextual Notes

Participants have not reached a consensus on the best method for overlapping plots, and there are unresolved issues related to the function definition and input arguments.

maxmilian
Messages
12
Reaction score
0
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. I've 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
 
Physics news on Phys.org
for i=1:40
plot(A(1:56,i),A(57:112,i))
pause(.1)
end
 
Thanks for your nice reply - what would I need to do if I wanted to have multiple plots in the same figure ?
 
doc subplot

OR (better)

Download subaxis from the file exchange and play with it and read the help file and documentation
 
subplot is unfortunately not what I need. I need the plots to overlap each other
 
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"
 
I resolved it by using "hold on"
But I am getting a error with my function when I am trying this ;

function figureplot(m)
load -ascii shapes.txt

for i=1:m
...

? Input argument "m" is undefined.

What I am 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.
 
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?
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
7K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K