I don't know the problem involved Backward difference.
Show older comments
Please load the“dataset.mat”file
(a). Develop first derivative function using Backward finite-difference
function [ diff_f ] = bdiff( f, x, h )
x_i = x;
x_ih = x-h;
diff_f = double((subs(f,x_i) - subs(f,x_ih)) / h);
end
(b). Calculate and display first derivative of given “velocity” data with respect to time
b-1. Unit of velocity is m/s
b-2. Set x-axis 0 to 30 and y-axis -5 to 5
b-3. Display should include differentiation of velocity from your function and “acceleration” data
(c). Caltulate the integration of velocity using Simpson's 1/3 rule ( 0sec to 30sec )
clear all
close all
clc
load('dataset.mat')
x = Time;
y = velocity;
y1 = acceleration;
h = Time(2) - Time(1);
N = 1000;
for i=2:N+1
bdiff_x = bdiff(y(i),x(i),h);
end
a = Time(1);
b = Time(2);
n = 30;
S = simpson(y,a,b,n);
figure
plot(x(1:N),bdiff_x,'b--','linewidth',1.5)
hold on
grid on
plot(x,y1,'g-','linewidth',1)
plot(x,S,'r--','linewidth',1)
legend('bDiff','Diff','S')
axis([0 30 -5 5])
xlabel('x')
ylabel('y')
I made a and solved B, but I can't even execute it. C couldn't do it. I need a help.
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!