# Generating Test Input Signals In MatLab®

In controls systems, test input signals can be used to test the transfer functions and the response of these transfer functions. You can also create your special test input signals in Matlab® with the ‘gensig()’ command.

Here we show you how to create test input signals in Matlab® with the ‘gensig()’ command. Check the code below and try this code in your Matlab® software.

YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!

On this post

## How To Use The ‘gensig()’ Command In MatLab®?

You can generate these signal types with the ‘gensig()’ command in Matlab®; sinus, square, and pulse periodical impacts. Check the code below;

``````>> [x,t]=gensig('square',3,18,1)

x =

0
0
1
0
0
1
0
0
1
0
0
1
0
0
1
0
0
1
0

t =

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

>> ``````

As you see above, there are four inputs of the ‘gensig()’ command in Matlab®. The first input is the type of signal which is ‘square’ here. You can also type other types of signals. The second input is the period of the signal which is 3 seconds. The third one is the total time that this signal will be created which is 18 seconds. And the last term in the parentheses of the ‘gensig()’ command is the sampling period of the signal through the total time.

If you check the result below; the first variable which is ‘x’ shows the signal’s value in each sample. And the second variable which is ‘t’ shows each sampling time.

The created signals can be used as inputs in the control system testing.

## Conclusion

The use of the ‘gensig()’ command in Matlab® to create basic signals for control systems is very simple.

Do not forget to leave your comments and questions below about the use of the ‘gensig()’ command in Matlab® below.

If you want further coding examples about the ‘gensig()’ command in Matlab®, inform us in the comments.