top of page
Search

# How to Use Sine Wave Block in MATLAB Simulink

## Introduction

We are going to learn how to use the Sine Wave block in MATLAB Simulink. This tutorial will guide you through the steps to create and configure a sine wave block, including setting parameters such as amplitude, frequency, phase, and bias.

## Setting Up the MATLAB Environment

To get started, open MATLAB and follow these steps to set up your working environment in Simulink:

1. Open MATLAB software.

2. Go to the SimulinkÂ block by clicking on it.

3. Click on Blank ModelÂ to create a new model where we will test the Sine Wave block.

## Adding the Sine Wave Block

1. Open the Library Browser.

2. Navigate to Sources.

3. Find and select the Sine WaveÂ block.

4. Drag and place the Sine Wave block into the working space (also known as the model window).

## Configuring the Sine Wave Block Parameters

Double-click the Sine Wave block to open its parameters window. Here, you can set the following parameters:

• Amplitude: Default is 1. You can keep it as 1 or change it as per your requirements.

• Bias: This adds a constant value to the sine wave. Default is 0.

• Frequency: Provide the frequency in terms of radians per second (Ï‰). For example, for 1 Hz, use 2Ï€2\pi2Ï€Â radians/second.

• Phase: Set the initial phase in radians.

• Sample Time: Default is continuous time (0).

For example, to set a frequency of 1 Hz, you would enter 2Ï€Ã—12\pi \times 12Ï€Ã—1Â in the Frequency field.

## Displaying the Sine Wave Output

To visualize the sine wave output:

1. Add a ScopeÂ block from the Library Browser (found under Sinks).

2. Connect the output of the Sine Wave block to the input of the Scope block.

## Running the Simulation

1. Click on the RunÂ button to simulate the model.

2. Initially, you might not get the proper sine wave output due to the default sample time or maximum step size settings.

3. To fix this, go to Configuration Parameters:

• Set the Maximum Step SizeÂ to 1Ã—10âˆ’41 \times 10^{-4}1Ã—10âˆ’4.

1. Apply the changes and run the simulation again to see a proper sine wave.

### Changing the Frequency

To change the frequency:

1. Double-click the Sine Wave block.

2. Set the Frequency to a new value. For example, setting it to 2 Hz would involve entering 2Ï€Ã—22 \pi \times 22Ï€Ã—2.

3. Apply the changes and run the simulation to see the updated waveform.

### Changing the Amplitude

To change the amplitude:

1. Set the Amplitude to a new value, e.g., 10.

2. Apply the changes and run the simulation.

### Changing the Phase

To change the phase:

1. Set the Phase to a desired value in radians. For example, to start the sine wave at 90 degrees, convert it to radians by using the formula 90360Ã—2Ï€\frac{90}{360} \times 2\pi36090â€‹Ã—2Ï€.

2. Apply the changes and run the simulation.

1. Set the Bias to a desired constant value. For example, set Bias to 10 to shift the sine wave upwards by 10 units.

2. Apply the changes and run the simulation.

## Example of Using Bias

If you set the Bias to 10, the sine wave will be shifted upwards by 10 units. Similarly, setting Bias to -10 will shift it downwards.

## Conclusion

The Sine Wave block in MATLAB Simulink is a versatile tool for generating sine waves with configurable parameters such as amplitude, frequency, phase, and bias. By adjusting these parameters, you can tailor the sine wave to meet specific requirements for various applications.