">

How do I generate signals using MATLAB?

MATLABSolutions. Oct 11 2025 · 7 min read
How to Generate Signals in MATLAB | Signal Generation Guide

Generating signals in MATLAB is one of the most common and fundamental tasks in signal processing, control systems, and communication projects. MATLAB provides built-in functions and toolboxes for creating continuous-time, discrete-time, and custom signals easily.

Here’s a complete explanation ?


1. Basic Concept

A signal in MATLAB is typically represented as a vector that varies with time.
You usually start by defining a time vector (t) and then use mathematical functions to generate the desired signal.

Example of time vector:

 
f = 5; % frequency in Hz t = 0:0.001:1; % time vector x = sin(2*pi*f*t); % sine wave plot(t, x); title('Sine Wave'); xlabel('Time (s)'); ylabel('Amplitude');

b) Cosine Wave

Similar to a sine wave, but phase-shifted by 90°.

 
f = 2; x = square(2*pi*f*t); plot(t, x); title('Square Wave');

d) Sawtooth Wave

A ramp-like signal.

 
x = sawtooth(2*pi*f*t, 0.5); plot(t, x); title('Triangular Wave');

f) Exponential Signal

Used in transient response and control system studies.

 
t = -5:0.1:5; x = t >= 0; plot(t, x); title('Unit Step Signal');

h) Impulse Signal

Defined as 1 at t = 0 and 0 elsewhere.

 
x = rand(1, length(t)); % uniform random signal plot(t, x); title('Random Signal');

or Gaussian noise:

 
x1 = sin(2*pi*2*t); x2 = 0.5*sin(2*pi*5*t); x = x1 + x2; plot(t, x); title('Composite Signal');

4. Signal Generation Using MATLAB Toolboxes

If you use Simulink:


5. Applications

Generated signals in MATLAB are widely used for: