Why plotting the first derivative of my function gets shrinked on its amplitud?

1 view (last 30 days)
Romni Yepez on 25 Sep 2017
Answered: VBBV on 29 Nov 2021 x = linspace(-2*pi,2*pi,100); y1 = sin(x); y2 = diff(y1); figure plot(y2);

Jan on 25 Sep 2017
Edited: Jan on 25 Sep 2017
What is the derivative of sin(a * t)?
a * cos(a * t)
Try it:
x = linspace(-2*pi, 2*pi, 100);
y1 = sin(x);
y2 = diff(y1);
figure
plot(x, y1, 'r');
hold('on');
plot(x, y2, 'g');
x2 = linspace(-2*pi, 2*pi, 200); % Time with double resolution
y3 = sin(x2);
y4 = diff(y3);
plot(x2, y4, 'b')

VBBV on 29 Nov 2021
x = linspace(-2*pi,2*pi,100);
y1 = sin(x); % original equation
y2 = diff(y1,1); %1st derivative
plot(y1); hold on;
plot(y2);
y3 = diff(y1,2) % 2nd derivative
y3 = 1×98
-0.0020 -0.0040 -0.0060 -0.0078 -0.0095 -0.0111 -0.0125 -0.0137 -0.0146 -0.0154 -0.0158 -0.0161 -0.0160 -0.0157 -0.0152 -0.0144 -0.0134 -0.0122 -0.0107 -0.0091 -0.0074 -0.0055 -0.0035 -0.0015 0.0005 0.0025 0.0045 0.0065 0.0083 0.0099
plot(y3); legend('Eqn','1st deriv','2nd deriv') 