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

조회 수: 1(최근 30일)
Romni Yepez
Romni Yepez 2017년 9월 25일
답변: VBBV 2021년 11월 29일
x = linspace(-2*pi,2*pi,100); y1 = sin(x); y2 = diff(y1); figure plot(y2);

답변(2개)

Jan
Jan 2017년 9월 25일
편집: Jan 2017년 9월 25일
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
VBBV 2021년 11월 29일
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')

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by