Is MATLAB solving Difference equations ?
이전 댓글 표시
Hi
I am wondering whether MATLAB is able to solve DIFFERENCE (recursive) equations, not differential ones. For example, difference equations as those frequently encountered in Economics.
Is a there a proxy method to do it?
Thanks
댓글 수: 1
Ahmed ElTahan
2016년 3월 25일
Here is a function I have built to calculate it with added example. https://www.mathworks.com/matlabcentral/fileexchange/56142-output-estimation-difference-equation
채택된 답변
추가 답변 (1개)
Matt J
2013년 7월 6일
0 개 추천
There is the filter() command. If you were looking for a symbolic solution, you might find something in the Symbolic Math Toolbox.
댓글 수: 3
Azzi Abdelmalek
2013년 7월 6일
Example
%y[n+2]-y[n+1]+0.25y[n]=u[n]
num=1
den=[1 -1 0.25]
n=0:0.1:5; % discrete time
x=heaviside(n) % input signal, in thise case heaviside signal
y=filter(num,den,x)
plot(n,y)
msh
2013년 7월 6일
Samir A. Farag
2014년 10월 23일
편집: Walter Roberson
2017년 2월 22일
% Mr. Azzi Abdelmalek, I have some notes on your answer.
%x(n+2)-1.3x(n+1)+0.4x(n)=u(n) % x(0)=0 and x(1)=0.
num=[0 0 1]; den=[1 -1 0.25];
k=0:1:5; % discrete time
% According to unit step definition, u(n)=1 for n>=0 and zero otherwise
% but using the heaviside function - and n is discrete and integer -
% contradicts this definition
% because it equals 0.5 - and not one - at n=0.
% So, to use k in discrete - and integre, i.e. 0, 1 , 2, .. etc,
% heaviside is not the proper function and you have to define it like my
% answer
x=[1 ones(1,5)]; % This yields outputs from y(0) to y(5)
y=filter(num,den,x)
% Also, the solution of difference equation is in discrete, so, to plot it,
use stem function
stem(k,y), grid
%Mr. Samir A. Farag, Teaching Assistant at H.T.I, Egypt
카테고리
도움말 센터 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!