-2

i am working on a code which gives me following error. i donno whr i am goin wrong..can somebody help me please ??? Subscript indices must either be real positive integers or logicals.

     Error in ==> gabor_fn at 23
  G(fix(Sx)+x+1,fix(Sy)+y+1) = exp(-nf*pi*((xPrime/Sx(yPrime/Sy).^2)).*cos(2*pi*f*xPrime);

my code is

                             Sx=10;                    
                             Sy=8;         
                             f=0.1;
                              nf=1;
                             k=1;
                             i=1;
                             theta =(i*15*pi)/180;
                               N = 12;


             x = -fix(Sx):fix(Sx)       
             y = -fix(Sy):fix(Sy)         
              [rowsx colsx numberOfColorChannelsx] = size(x);        
               % Get size of existing image B. 
                [rowsy colsy numberOfColorChannelsy] = size(y);        
              % See if lateral sizes match.         
             if rowsy ~= rowsx || colsx ~= colsy         
             % Size of B does not match A, so resize B to match A's size.         
             y = imresize(y, [rowsx colsx]);         
             end
              xPrime = x * cos(theta) + y * sin(theta);             
              yPrime = y * cos(theta) - x * sin(theta);                      
           G(fix(Sx)+x+1,fix(Sy)+y+1) = exp(-nf*pi*((xPrime/Sx).^2+
          (yPrime/Sy).^2)).*cos(2*pi*f*xPri0me);    //THIS IS THE LINE WHERE I GET ERROR AND PARTICULARLY **G(fix(sx)+x+1,fix(sy)+y+1)**
vidya
  • 59
  • 2
  • 8
  • 2
    Please format and indent your code so that it is readable by human beings. Also, proper capitalization and use of punctuation is appreciated on StackOverflow. – horchler Nov 18 '13 at 16:54
  • See this question for the generic solution to this problem: http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol – Dennis Jaheruddin Nov 18 '13 at 17:35

1 Answers1

2

Run the code with dbstop if error, you will find that one of these is not a real positive integer or logical:

yPrime/Sy
fix(Sx)+x+1
fix(Sy)+y+1

OR you will find that you overloaded a function, that is one of these will give an error:

fix(0.5)
exp(0.5)
cos(0.5)

I bet this does the trick, but otherwise please give the values and sizes of all variables used at the line when the code stops.

Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122