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)
Show older comments
How to represent this equation in matlab Equation: X(i, j) = aX(i, j − 1) + bX(i − 1, j − 1) + cX(i − 1, j)
0 Comments
Answers (3)
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
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.
0 Comments
cicila madassery
on 5 Nov 2014
Edited: cicila madassery
on 5 Nov 2014
1 Comment
Torsten
on 5 Nov 2014
I think it will work if you replace "For" by "for" in the program.
Best wishes
Torsten.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!