How To Execute "if-else" Statement.

Hi,
I am having problem to execute an "if-else" statement in matlab of the foll. eqtn.
Xc=sum(i:1 to 3)sum(j:1 to 3)[(a(i,j)-a(m))*h(i,j)*x]/sum(i:1 to 3)sum(j:1 to 3)[(a(i,j)-a(m))*h(i,j)];
Yc=sum(i:1 to 3)sum(j:1 to 3)[(a(i,j)-a(m))*h(i,j)*y]/sum(i:1 to 3)sum(j:1 to 3)[(a(i,j)-a(m))*h(i,j)];
Where:
  1. sum(i:1 to 3)=represents summation where i goes from 1 to 3
  2. a(i,j): 3x3 matrix[3 6 8; 2 5 6; 9 4 5];
  3. a(m): middle element of the matrix a(i,j);
  4. h(i,j)={ 1, if a(i,j)>=a(m) &
  5. 0, if a(i,j)<a(m).
  6. [x y]=meshgrid(-1:2/2:+1, -1:2/2:+1).
Can anyone implement the foll. eqtn by correctly stating the condition of h(i,j).
Thanking You!

댓글 수: 4

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 3일
편집: Azzi Abdelmalek 2012년 9월 3일
if condition1
calcul1
elseif condition2
calcul2
....
elseif condition n
calculn
end
Image Analyst
Image Analyst 2012년 9월 3일
What do you mean by "middle"? The (2,2) element, or the median value? I think a(m) means a(2,2), right? Is this homework (looks like it)?
Dishant Arora
Dishant Arora 2012년 9월 3일
you have asked the same question again. http://www.mathworks.in/matlabcentral/answers/47101#answer_57577 didnt it help you out. you tried doing it.?? if you are facing any problem implementing that, u should make a comment there rathar then creating new question.
Jan
Jan 2012년 9월 3일
Please, Pranjal, do not post multiple questions for one problem. This wastes the time of the ones, who want to help.

댓글을 달려면 로그인하십시오.

답변 (0개)

질문:

2012년 9월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by