# Simple way to plot sine wave in MATLAB

# An easy way to plot a sine wave in Matlab

It is one of the easiest ways to plot a sine wave in Matlab. As everyone knows that it is plotted on python which is a user-friendly language. You have to be more friendly with Python than another language to gain more knowledge about sine wave.

Yes, we can do sine wave using other language but for Matlab, you have to use Python. Python is mostly popular for machine level language as well as for Artificial Language. But we consider it as a cross-platform language. It can be used for games, AI, machine-level language, web etc.

The sine wave is normally like an analog wave where you will see a wave on a graph denoted highest as 1 and lowest as 0.

##### Things you need to know before you plot a sine wave:

- You need to install python or python 3.
- You need to install python libraries that are numpy and matplotlib.
- And you have to install pip or pip3.
- And you can install the library by
**sudo pip or pip3 install and the library name.**

import numpy as np import matplotlib.pyplot as plt a = np.arange(0,3*np.pi,0.1) b = np.sin(x) plt.title("sine wave form") plt.plot(a,b) plt.show()

import numpy as np from matplotlib import pyplot as plt a = np.arange(1,11) b = 2 * a + 5 plt.title("Matplotlib ") plt.xlabel("x axis caption") plt.ylabel("y axis caption") plt.plot(a,b) plt.show()

import numpy as np from matplotlib import pyplot as plt a = np.arange(2,12) b = 3 * a + 6 plt.title("Matplotlib demo") plt.xlabel("x axis caption") plt.ylabel("y axis caption") plt.plot(a,b,"ob") plt.show()

import numpy as np import matplotlib.pyplot as plt a = np.arange(0, 3 * np.pi, 0.1) b = np.sin(x) plt.title("sine wave form") plt.plot(a, b) plt.show()

from matplotlib import pyplot as plt a = [5,8,10] b = [12,16,6] a2 = [6,9,11] b2 = [6,15,7] plt.bar(a, b, align = 'center') plt.bar(a2, b2, color = 'g', align = 'center') plt.title('Bar graph') plt.ylabel('x axis') plt.xlabel('y axis') plt.show()

## Leave a Reply