Debugger won't step into software at first line with this code.
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
My code is:
function n = palin_product( dig,lim )
    if isnumeric(dig)== false
        n = 0;
        return;
    end
    if isnumeric(lim)==false
        n = 0;
        return;
    end
    c = floor(dig)
    multiplier1=10^c;
    multiplier1 = multiplier1-1;
    L=num2string(lim);
    len = length(L)
    if ceil(L/2)-floor(L/2)==0
        nucount=L/2;
    else
        numcount =floor(L/2);
    end
    for q =lim:-1:1
        consider= q;
        L = num2string(q)
        if ceil(L/2)-floor(L/2)==0
            nucount= L/2;
        else
            nucount= floor(L/2);
        end
        test =false;
        for count = 0:nucount-1
            if L(0+count) == L(len-count);
                test =true
            else
                test = false
            end
            if count ==true
                n = q;
            end
        end
    end        
    if test ==false
        n =0;
    end
end
THe description of the problem is:

Matlab will not let me start tracing software to look for errors in its behavior. It won't got to the first "if" statement when I call the function. What is wrong?
댓글 수: 2
  Walter Roberson
      
      
 2016년 12월 10일
				It would not stop there if the function is not being called, or if it is being called with too many arguments. Re-check the file name, and make sure that you have dig and lim defined when you invoke the function. Are any error messages being produced?
  Walter Roberson
      
      
 2016년 12월 10일
				Undefined function or variable 'num2string'.
num2str is the function name.
if L(0+count) == L(len-count);
Remember that MATLAB subscripts start at 1.
                test = false
When the test becomes false then you should not be continuing the iterations. See "break"
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

