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

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)

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.

2 Comments

I have to take values of i and j from 0 to 100
This equation is for representing the current pixel with respect to its neighbours.

Sign in to comment.

% 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.
The code is showing the following error
Illegal use of reserved keyword "end".

1 Comment

I think it will work if you replace "For" by "for" in the program.
Best wishes
Torsten.

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Asked:

on 5 Nov 2014

Commented:

on 5 Nov 2014

Community Treasure Hunt

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

Start Hunting!