top of page
Writer's picturelms editor

How to Use Sine Wave Block in MATLAB Simulink

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.

Adjusting Frequency and Amplitude

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.

Adjusting Phase and Bias

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.

Adding a Bias

To add a bias:

  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.

12 views0 comments

Comments


bottom of page