Matlab Material
Matlab Material
We cannot save the command window. editor window can be saved but not cmd window.
Saturation Block:
It is used to eradicate overflow and underflow conditions.
Lower Limit/Min and Upper Limit/max values are defined and we can only enter value in
between that range.
Switch: It is used to develop/design a single and simple if-else logic.(one if, one else).
Manual Switch: It has two input ports and is already connected with upper input. To connect to
lower input double-click on the switch.
Multiport Switch: It has a minimum of 3 inputs and one control port. The control port is used to
select the required input port.
Logical Operators:
Sub-system: It is used to remove or reduce the visual complexity. Select the components and
use ctrl+G subsystem is created.
Inport/outports are used to send/transfer their values between various sub systems.
Relational Operators:
Mux: Any no.of inputs single output. It accepts only similar data types. In mux we cannot choose
the output datatype.
Demux: Single input and multiple output.
Bus: Bus accepts dissimilar data type inputs. In bus we can choose the datatype of the output.
Reset State: In this the output after reaching negative value is reset to zero and again the output
starts from there.
There is no difference in output between held and reset state when numerical values are used.
Triggered subsystem:
In this the count starts from 1. To start count from 0 change the initial value of unit
delay block from 0 to -1.****interview question****
To change the counter value to a maximum of 10 we use switch block. -shot0028.png
Merge Block:
It takes any no.of inputs but only one output. Here output is most recently activated
input subsystem.
It is applicable for only conditionally/atomic executed sub systems.
Limitation: It is not applicable for virtual sub systems and we encouner an error.
Error: An input signal to merge block must be orginate from a conditionally executed sub
system.
MERGE
MUX
OEM – Original Equipment Manufacturers Ex: Toyota, Benz, Honda, Nissan, Renault, Audi,
FCA, Caterpillar
Service Based Companies: L&T, KPIT, Alten, Wipro, Infosys, Capgemini, Harman
In MIL testing the test cases are written in an excel sheet and are imported using a signal
builder the output is then verified with the expected output. The excel file should contain only
one sheet.
To import file double-click on signal builder in File menu > Import from file(select the test
case file.xlsx) and open. Then Placement for selected data > replace exsiting dataset > click
confirm > Click OK and Apply.
Stateflow : If you want to design sudden changes in dynamic system we use stateflow.
Ex : Breaks, gear, indicators
Simulink : If you want to design continuous changes in dynamic system we use simulink.
Ex: steering
Library Browser > Stateflow
Stateflow consists of 4 modules chart, sequence viewer, chart-transition table, truth table.
The difference between stateflow(pale yellow) and simulink(white) is background color.
Simulink is the product of MATLAB, Stateflow is the product of simulink.
It is difficult and requires more no.of blocks to design sudden changes in simulink.
In stateflow animation is possible but not in simulink.
State Components:
1. Entry(en)
2. During(du)
3. Exit(ex)
Examples:
1.Functioning of Tubelight (x is output, u is input)
Default Transition
State Condition
2. System has 4 states. Transition can occur from State 1 to State 2 when input is greater
than 0. After 10 secs transition can occur from State 2 to State 3. After 15 msec transition
can occur from State 3 to State 4. After 5sec transition can occur from State 4 to State 1.
3.Traffic Lights System has 3 states(Red, yellow, green). Default transition is at yellow state.
After 4 sec transition occurs b/w yellow to green. When transition occurs yellow light
should be 0(OFF). After 3 sec transition occurs b/w green to red. When transition occurs
green light should be 0(OFF). After 2 secs transition occurs b/w red to yellow. When
transition occurs red light should be 0(OFF).
Absolute(ABS) Block: It performs modulus operation. If the input is negative or positive value it
gives only positive values as output.
Selector Block: To select a particular input signal from a no.of input signals we use selector
block. The input is selected as per index.
Selector
MUX
2. Parallel(AND): In this all the sates will be active at a time, but execution is performed
according to the execution order. We can change the execution order.
The state blocks are showed with dotted border lines.
Child States/
Sub States
Parent State
Min-Max Block : It gives max/min value as output from a given no.of inputs.
Interview Questions:
Matlab Model Life Cycle:
Requirements – Develop/Design – MIL test – Auto code generation – SIL test – PIL test – HIL
test.
SIL Test:
Improve the quality of the product SIL test is carried out.
We can use same test cases for MIL and SIL test. In SIL we can mainly focus on data types,
because we are working on the code here to check satisfying different conditions.
It is used for rounding process.