forward backward and central approximations
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Directed Graphs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!