In: Computer Science
In MATLAB:
x = [1 3 4 6 7 10 11 15 16]
y = [20 24 25 30 32 34 39 41 48]
This is an exercise in numerical differentiation.
Using the central difference method where possible, find dy/dx for the data set provided. Plot results.
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
clc
clear all
close all
format long
x = [1 3 4 6 7 10 11 15 16];
y = [20 24 25 30 32 34 39 41 48];
dydx=[];
i=1;
dydx(1)=(y(i+1)-y(i))/(x(i+1)-x(i));
for i=2:length(x)-1
dydx(i)=(y(i+1)-y(i-1))/(x(i+1)-x(i-1));
end
dydx(end+1)=(y(end)-y(end-1))/(x(end)-x(end-1));
disp(dydx)
plot(x,dydx);
Kindly revert for any queries
Thanks.