-3

so I built two normal distributions.. I want to to combine both into a single image, with the two images overlapping partially to look something like this: two plots http://www.uark.edu/misc/lampinen/tutorials/image8BK.JPG

is there any way to do this in matlab?

EBH
  • 10,350
  • 3
  • 34
  • 59

1 Answers1

0

Use hold on keyword between different plots. For example:

   plot(x,'r');

   hold on;

   plot(y,'b');

It will plot both x and y in red and blue colors on same graph.

shaifali Gupta
  • 380
  • 1
  • 4
  • 16
  • x and y should have different values, otherwise x will replace y – shaifali Gupta Aug 14 '16 at 07:00
  • so here is what I ended up doing because what you told me wasn't getting both of the distributions to be equal size and fit evenly on the same axes: >> x = [-2.5:.1:2.5]; >> norm = normpdf(x,0,1) >> y = [-2.5:.1:2.5]; >> horm = normpdf(y,-1.5,1); >> plot(x,norm) >> hold on – FastBallooningHead Aug 14 '16 at 08:19
  • next I manually edited the x axis to go from -4 to 4; then: >> plot(y,horm); now my problem is as follows: for some reason, the distribution called "horm" gets plotted, but the leftmost quarter of the distribution is totally missing ...... any ideas why this is happening? – FastBallooningHead Aug 14 '16 at 08:24
  • I guess this is just in plotting. Try manually extending the x-axis to left from axis properties of matlab fig plot – shaifali Gupta Aug 14 '16 at 08:30
  • Can you tell why have you added -1.5,1 in normpdf of y. – shaifali Gupta Aug 14 '16 at 08:48
  • because I want the two distributions to cross at about the -.75 mark on the x axis, and setting the mean of "horm" to -1.5 with a standard deviation of 1 accomplishes this – FastBallooningHead Aug 14 '16 at 09:03
  • attach a snapshot of the plot you are getting and also the values that you are plotting on x and y for both curves – shaifali Gupta Aug 14 '16 at 09:09
  • everything about the x and y values is listed in my code above (x has a mean of 0 and standard deviation of 1 and y has a mean of -1.5 and a standard deviation of 1...and both distributions are both 5 units in length).....here's a link to the image: http://imgur.com/a/Spn1D – FastBallooningHead Aug 14 '16 at 09:27