Here's an implementation of a Turing machine in MATLAB as a class:
main.m2145 chars57 linesThis implementation includes a constructor to set the initial tape, state, transition function, accept states, and reject states of the Turing machine. The run method runs the Turing machine until it reaches either an accept or reject state.
Note: This implementation assumes that the input tape is a MATLAB array, with the tape head initially at the first element of the array. The transition function is expected to be a MATLAB containers.Map object with keys of the form "currentState,currentSymbol". The values of the containers.Map object should be of the form [newSymbol,direction,newState], where newSymbol is the symbol to write to the tape, direction is either 'L' (move tape head to the left) or 'R' (move tape head to the right), and newState is the new state of the Turing machine.
gistlibby LogSnag