Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Problem with difference equation
Replies: 4   Last Post: Jun 27, 2010 8:48 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
for_next

Posts: 64
Registered: 10/12/07
Problem with difference equation
Posted: Jun 27, 2010 4:52 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi folks, I have to use difference equation to find second derivative of sin function.
This is the function g1*sin(2*pi*t/T). I use approximation with central finite difference of second order with second-order accuracy. It's it fpp(x) = ( f(x+h) -2f(x) + f(x-h) ) / h^2.... When i wrote simple program to prove that this approximation works, and it is:

clear, clc
% params of sin function
t = 0:0.01:1;
Ts = 0.01;
g1 = 0.6; T = 0.2;
% the second order differential of sin function
tpp = -4 * g1 * pi^2 * sin(2 * pi * t / T) / T^2;
% the second order difference of sin function
tdd = (sin(2 * pi * (t+Ts) / T) - 2*sin(2 * pi * t / T) + sin(2 * pi * (t-Ts) / T)) /Ts^2;
% plot the result
plot(t, t1dpp, '-b', t, t1dd, '-r')

Then I plotted the result the sins are different - with differential equation the Amp it (-600; 600) and with difference it's (-1000; 1000).
I'm new to difference equation i try to do my best, but i can't managed with this problem. Can someone help me ? I need the approximation to be same as the second derivative of sin function.
Thanks !



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.