Introduction to Stateflow with Applications