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

Matlab: Custom Graph

  1. Nov 29, 2008 #1

    Air

    User Avatar

    How can I draw a graph on Matlab which is custom. I want to add peaks to a curve. I've drawn a simple quadratic curve but want to add some custom peaks. What code would I type? Is is possible to do such a thing on Matlab? Thanks in advance.
     
  2. jcsd
  3. Nov 29, 2008 #2

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    If you have written a function to calculate a quadratic, write a function for a Gaussian and add the matrices before plotting.
     
  4. Nov 29, 2008 #3

    Air

    User Avatar

    Not to calculate the quadratic, I have plotted:

    Code (Text):
    x=0:.5:20;
    y=(x-5).^2+10;
    plot(x, y);
    But I want to add some peaks. Make a custom graph. Sorry but I don't understand what you mean.
     
  5. Nov 29, 2008 #4
    What do you mean you "want to add peaks to a quadratic"?

    I can probably help you out with this since I've been using Matlab for years, but I've never heard that particular phrase before.
     
  6. Nov 29, 2008 #5

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    Code (Text):


    clear all;

    x = 0:0.01:20;

    y = (x-5).^2+10;

    y1 = 25*exp(-((x-10).^2)/0.5);

    y2 = y+y1;

    plot(x,y,x,y1,x,y2);

     
    From here add more layers of the Gaussian that I have set up for you.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Matlab: Custom Graph
  1. Matlab graph (Replies: 14)

Loading...