Hi everyone!(adsbygoogle = window.adsbygoogle || []).push({});

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 Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Plot diff plot from a periodic function

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**