Simulink & Matlab Interview Question and Answers For Automotive , Aerospace etc.


1. What is the difference between Simulink and Stateflow
Ans . Simulink is used to implement dynamic systems where the state of the system varies with time and thus obeys differential equations involving time derivatives .
On the other hand Stateflow is based on State machine where the system have a finite number of states and the system can be in exactly one of a finite number of states at any given time.
So we can say that, at a given instant of time the state of a Simulink model can be computed using differential equation and is not known in advance , however in case of Stateflow model all the possible states in which the system can be are know beforehand the Simulation of Stateflow model.
Simulink is generally used to model systems which are represented majorly by means of mathematical equation (algebraic equations and differential equation) while Stateflow is generally used to model a system represented majorly by fixed number of States as in Finite State Machine.

==========================================
Additional Inputs ( Which can be helpful in understanding)

Stateflow is majorly useful for
1. Logical and conditional statements
2. Truth Tables
3. Scheduling ( in Stateflow its very easy using Tick event , however to implement the same in Simulink you have to implement separate counter , create separate  subsystem etc.)
4. Event Driven Systems

Simulink responds to continuous changes (Suspension in Cars)
Stateflow responds to instantaneous changes (Transmission Gears)


Any stateflow model can also be modeled using Simulink and same is true vice versa
But if you try to convert a Simulink Model to Stateflow model or vice versa , you will find it easier to implement Stateflow using simulink modelling approach than to implement a Simulink Model using Stateflow modelling approach Simulink ( which is possible by adding multiple if-else or switch blocks ) but the final result will look very ugly and cumbersome.

Debugging is easy in simulink but readability and code generation are easy in stateflow.  

To design a reactive system or event driven system we should prefer stateflow instead of simulink. because we can control an event in stateflow in better way compare to simulink .  

To implement logical statement in simulink your model becomes visually difficult to be analysed after coding(Code Generation)


Complex state machine: Stateflow
Complex mathematical process: Simulink blocks
Others: both of Stateflow and Simulink are fine  

==========================================

I will be adding more question and answers whenever time permits...
Request you to add you comments and opinions and possible correction in the answers if you find any...
You can provide questions that you came across while attending interviews and i will add them to the list for the benefit of the others... 
You can provide questions that you came across while attending interviews and i will add them to the list for the benefit of the others... 

Comments

Popular posts from this blog

What is .TLC (Target Language Compiler) and MEX file in Matlab Simulink

Real World Value Vs Stored Integer In Simulink ( Fixed Point Number Debunked )