Matlab: Custom Graph Drawing & Adding Peaks

  • Context: MATLAB 
  • Thread starter Thread starter Air
  • Start date Start date
  • Tags Tags
    Graph Matlab
Click For Summary

Discussion Overview

The discussion revolves around creating custom graphs in Matlab, specifically focusing on adding peaks to a quadratic curve. Participants explore methods for combining different functions to achieve the desired graphical representation.

Discussion Character

  • Exploratory, Technical explanation, Homework-related

Main Points Raised

  • One participant inquires about the possibility of adding custom peaks to a quadratic curve in Matlab and requests guidance on the necessary code.
  • Another participant suggests writing a Gaussian function and combining it with the quadratic function before plotting.
  • A third participant shares their existing code for plotting a quadratic curve and expresses confusion about how to incorporate peaks into it.
  • A participant questions the meaning of "adding peaks to a quadratic," indicating a lack of familiarity with the terminology used by the original poster.
  • A later reply provides a code example that combines a Gaussian function with the quadratic curve, suggesting the addition of more layers of Gaussian functions for further customization.

Areas of Agreement / Disagreement

The discussion does not reach a consensus, as participants express varying levels of understanding and propose different approaches to the problem.

Contextual Notes

Participants have not clarified the specific characteristics of the "peaks" they wish to add, leading to ambiguity in the discussion. There is also a lack of detail regarding the desired appearance or mathematical properties of the custom graph.

Who May Find This Useful

This discussion may be useful for individuals interested in Matlab programming, particularly those looking to enhance their graphing capabilities with custom functions and overlays.

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.
 

Similar threads

Replies
5
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
7
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
7K