Plot diff plot from a periodic function

In summary, the individual is seeking a solution for drawing the derivative of their sawtooth periodic function, using the diff() function. They have already attempted to use diff(y,x) but it did not work. They are looking for guidance on how to use the diff() function to find the derivative of their function.
  • #1
matinking
17
0
Hi everyone!
I've written a M-file to draw a sawtooth periodic function as below:

function y = sawtooth_w(x)
% We find the period number of every element
% in the input vector
p = 1;
%k = 4;
tn = ceil((x+p)/(2*p));

% and we subtract that corresponding period from
% the base value. We want final values from -1 to 1
y = ((x - tn*2*p) + 2*p)/p*4;


clear, clc, close all

x = -6 : .01 : 6;
y = sawtooth_w(x);
plot(x,y)

axis([0 6 -5 5])
xlabel('\bf{Time(sec)}')
ylabel('\bf{Magnetic flow(Web)}')


now, I want to draw derivative of this function which consists of impulse signals.
i tried to use diff(y,x) to extract the derivative but it didn't work

does anybody has any solution?
 
Physics news on Phys.org
  • #2
thanks in advance!</code>You can use the diff() function to find the derivative of a function. The syntax is diff(y,x) where y is the function and x is the independent variable. For example, if you have the function y = x^2 and you want to find the derivative of that function, you would use diff(y,x) which would give you 2x.If you want to find the derivative of your sawtooth periodic function, you would use diff(y,x) and substitute y with your sawtooth_w(x) function. That should give you the derivative of the sawtooth periodic function.Hope this helps!
 

1. What is a periodic function?

A periodic function is a mathematical function that repeats itself at regular intervals, called the period. This means that the output values of the function will be the same at certain points along the x-axis.

2. How is a plot diff plot different from a regular plot?

A plot diff plot, short for "plot difference plot", is a type of graph that shows the difference between two sets of data. In the case of a periodic function, it would show the difference between the function and a straight line. This allows for a clearer understanding of the changes in the function over time.

3. What is the purpose of using a plot diff plot for a periodic function?

A plot diff plot is useful for understanding the behavior of a periodic function, as it allows for the identification of any patterns or changes in the function over time. It can also be used to compare different periodic functions and determine which one has a more stable or predictable pattern.

4. How is the period of a periodic function represented on a plot diff plot?

The period of a periodic function is typically represented as the distance between two consecutive peaks or valleys on the plot diff plot. This can also be seen as the distance between two points where the function crosses the straight line on the graph.

5. Can a plot diff plot be used for any type of periodic function?

Yes, a plot diff plot can be used for any type of periodic function, including trigonometric functions such as sine and cosine, as well as other types of periodic functions like square waves or sawtooth waves. As long as there is a clear pattern of repetition, a plot diff plot can be used to analyze and compare the function.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
963
Back
Top