How to represent this equation in matlab Equation: X(i, j) = aX(i, j − 1) + bX(i − 1, j − 1) + cX(i − 1, j)

7 views (last 30 days)
How to represent this equation in matlab Equation: X(i, j) = aX(i, j − 1) + bX(i − 1, j − 1) + cX(i − 1, j)

Answers (3)

Torsten
Torsten on 5 Nov 2014
Your question is unclear for me.
Are you in search of a closed-form solution for the above linear 2d-recurrence relation ?
Best wishes
Torsten.

Torsten
Torsten on 5 Nov 2014
% Allocate X-Array
X=zeros(101,101);
% Set boundary values at lower and left edge for X
X(1,1:101)=1;
X(1:101,1)=1;
% Set Parameters
a=1;
b=0.5;
c=0.25;
% Calculate field values
For jj=2:101
For ii=2:101
X(ii,jj)=a*X(ii,jj-1)+b*X(ii-1,jj-1)+c*X(ii-1,j);
end
end
I started from 1 instead of 0 and thus went through until 101 instead of 100.
Best wishes
Torsten.

cicila madassery
cicila madassery on 5 Nov 2014
Edited: cicila madassery on 5 Nov 2014
The code is showing the following error
Illegal use of reserved keyword "end".

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!