MATLAB 08-2 (debugging)

신예진·2022년 2월 1일
0

Matlab Simulink

목록 보기
16/17

Debugging
To create is God, To error is human

1) program bug (error)

bug that is detected by Matlab (syntax error) → easy to find
bug that gives wrong answer → not easy to find
debugging : process of finding bugs and fixing them (* step by step)

2) Debugging takes a major portion of programming

3) No.1 rule of debugging

check values of variables (ex, remove ';' at the end)

Style

4) makes program script easy to understand

5) does not affect computation, but very important

① put comments(%) as many as possible
	begginning of program → summary of what program does

② indent dependent statements (if, for, while)
	if (i<0.5)
    	i = i + 3;
        end
        
    	if (i<0.5)
            i = i + 3;
        end
        
③ put blank line between sections

④ one equation (command) in one line

Comment / Uncomment

command+/ (comment) : insert comment marker in front
command+option+/ (uncomment) : remove comment marker from front

0개의 댓글