forward backward and central approximations
2 views (last 30 days)
Show older comments
I'm pretty sure I have the code right to plot the graphs for the forward backward an central approximations of a derivative (although I'm not positive). The only thing I need to do now is have it output a value for x=3.2. I'm not quite sure how to do this. Here is my code so far. clear; close all; clc;
delx = 0.05;
x = 0.01:delx:5;
y = 1000.^(x/17);
fig = figure();
set(fig,'color','white');
plot(x,y,'linewidth',2);
xlabel('x');
ylabel('y');
grid on;
yforward = diff(y) ./ delx;
hold on
plot(x(1:end-1)-delx/2,yforward,'r-','linewidth',2);
ybackward = diff(y) ./ delx;
hold on
plot(x(1:end-1)+delx/2,ybackward,'g-','linewidth',2);
ycentral = diff(y) ./ delx;
hold on
plot(x(1:end-1),ycentral,'b-','linewidth',2);
If someone could tell me how to output that value (and also make sure the code is right for the approximations) that would be awesome. Thanks.
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!