Adding custom peaks to a quadratic curve in Matlab

  • Context: MATLAB 
  • Thread starter Thread starter Air
  • Start date Start date
  • Tags Tags
    Graph Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 8K views
Air
Messages
202
Reaction score
0
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.
 
Physics news on Phys.org
If you have written a function to calculate a quadratic, write a function for a Gaussian and add the matrices before plotting.
 
Not to calculate the quadratic, I have plotted:

Code:
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.
 
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.
 
Code:
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.