- #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?
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?