# Category: How to plot a sine wave

By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up. I am trying to show a visual representation of a few cycles of a 50Hz and 60Hz sine wave at Volts overlapping and trying to find out how to create this as a chart in Excel.

Plotting sine function Python

Does anyone know how to do that? You need a monotonic time-base. Then, you apply the sin function to the values from the first column, in a second column. You now have a sine-wave dataset! Plot it:.

For different frequencies, you can incorporate a scaling value into the time-value before it is fed into the sin function. This will let you arbitrarily scale the time-units between multiple columns, if needed. I actually worked this out myself in Excel and came up with the following which suits what I needed it for:.

Sign in to answer this question. Unable to complete the action because of changes made to the page. Reload the page to see its updated state. Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.

Select the China site in Chinese or English for best site performance. Other MathWorks country sites are not optimized for visits from your location. Toggle Main Navigation. Search Answers Clear Filters. Answers Support MathWorks. Search Support Clear Filters. Support Answers MathWorks.

Vote 2. Answered: Quyn Reid on 3 Apr at Have you ever used a graphing calculator? You can enter an equation, push a few buttons, and the calculator will draw a line. In this exercise, we will use our turtle to plot a simple math function, the sine wave. The sine function, sometimes called the sine wave, is a smooth, repetitive oscillation that occurs often in many fields including mathematics, physics, and engineering.

A single repetition is shown below. Note that the x axis is given in degrees. For this lab, we will use the math library to generate the values that we need. To help you understand the sine function, consider the following Python program. As you can see, the sin function from the math library takes a single parameter.

The program above shows us that the sine of 90 degrees is 1. Note that the figure above agrees with that. Try a few other values, like 0 degrees, degrees, 38 degrees, and so on. You should be able to match the results up with the picture shown above.

It might be even more interesting to iterate through a sequence of angles and see the value of the sine function change. Try it for angles between 0 and degrees. What do you notice about the results? If the tail is down, a line will be drawn from the previous location to the new location. Recall that the default turtle screen starts with the turtle in the middle at position 0,0.

You can think of the screen as a piece of graph paper. The x axis runs horizontally and the y axis runs vertically. The point where they meet in the middle is 0,0. Positions to the left of the center have an x value that is negative.

Positions that are below the center have a y value that is negative. Experiment with the method to make sure you understand the coordinate system of the screen. Try both positive and negative numbers. Now we can put the two previous programs together to complete our plot. Here is our sequence of steps. You probably think that the program has errors since it does not draw the picture we expect. Maybe you think it looks a bit like a line? What do you think the problem is?Sign in to comment. Sign in to answer this question. Unable to complete the action because of changes made to the page.

Reload the page to see its updated state.

## Learn How to Plot a Sine Wave in Excel

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:. Select the China site in Chinese or English for best site performance. Other MathWorks country sites are not optimized for visits from your location. Toggle Main Navigation. Search Answers Clear Filters. Answers Support MathWorks. Search Support Clear Filters. Support Answers MathWorks. Search MathWorks. MathWorks Answers Support.

Open Mobile Search. Trial software. You are now following this question You will see updates in your activity feed. You may receive emails, depending on your notification preferences. I need to plot a sine wave. Francis Arthur-Worsop on 17 Nov Vote 0. Commented: Francis Arthur-Worsop on 17 Nov Accepted Answer: Geoff Hayes.By Yang Kuang, Elleyne Kase. Knowing how to graph trig functions allows you to measure the movement of objects that move back and forth or up and down in a regular interval, such as pendulums. Sine functions are perfect ways of expressing this type of movement, because their graphs are repetitive and they oscillate like a wave.

### I need to plot a sine wave

The waves crest and fall over and over again forever, because you can keep plugging in values for. The following steps show you how to construct the parent graph for the sine function. Keep in mind that because all the values of the sine function come from the unit circle, you should be pretty comfy and cozy with the unit circle before proceeding.

You can graph any trig function in four or five steps. Here are the steps to construct the graph of the parent function. No matter what you put into the sine function, you get an answer as output, because. Therefore, the domain of sine is all real numbers, or. On the unit circle, the y values are your sine values — what you get after plugging the value of. So in the x- direction, the wave or sinusoid, in math language goes on forever, and in the y- direction, the sinusoid oscillates only between —1 and 1, including these values.

In interval notation, you write this as [—1, 1]. To complete this step, use your knowledge of the range from Step 1. You know that the highest value that sin x can be is 1.

At what angles s does this happen? You also can see that the lowest value of sin x can be is —1, when the angle x is. Using the five key points as a guide, connect the points with a smooth, round curve. The figure approximately shows the parent graph of sine. Remember that the parent graph of the sine function has a couple of important characteristics worth noting:. It repeats itself every 2 — pi radians. This repetition occurs because 2-pi radians is one trip around the unit circle — called the period of the sine graph — and after that, you start to go around again. The graph of sine is called periodic because of this repeating pattern. The sine function has degree-point symmetry about the origin.

If you look at it upside down, the graph looks exactly the same. For example. Mary Jane Sterling aught algebra, business calculus, geometry, and finite mathematics at Bradley University in Peoria, Illinois for more than 30 years.

How to Graph a Sine Function. About the Book Author Mary Jane Sterling aught algebra, business calculus, geometry, and finite mathematics at Bradley University in Peoria, Illinois for more than 30 years.Get x values of the sine wave.

### How to Graph a Sine Function

Amplitude of the sine wave is sine of a variable like time. Plot a sine wave using time and amplitude obtained for the sine wave. Give a title for the sine wave plot. Give x axis label for the sine wave plot. Give y axis label for the sine wave plot.

Display the sine wave. Toggle navigation Pythontic. Sine waves have the shape of sine curve. The X-axis of the sine curve represents the time. The Y-axis of the sine curve represents the amplitude of the sine wave. The amplitude of the sine wave at any point in Y is proportional to the sine of a variable. A cycle of sine wave is complete when the position of the sine wave starts from a position and comes to the same position after attaining its maximum and minimum amplitude during its course.

The time taken to complete one cycle is called the period of the sine wave. The frequency of the sine wave is given by number of cycles per second.

The distance covered by a cycle measures the wavelength of the sine wave. Examples of sine waves include the oscillations produced by the suspended weight on spring and the alternating current. NumPy has the sin function, which takes an array of values and provides the sine value for them.

Using the numpy sin function and the matplotlib plot a sine wave can be drawn. Example: import numpy as np import matplotlib.A sine wave or sinusoid is a mathematical curve that describes a smooth periodic oscillation. A sine wave is a continuous wave.

## How to plot Sine Cosine wave in MATLAB

It is named after the function sineof which it is the graph. It occurs often in pure and applied mathematicsas well as physicsengineeringsignal processing and many other fields. Its most basic form as a function of time t is:. The sine wave is important in physics because it retains its wave shape when added to another sine wave of the same frequency and arbitrary phase and magnitude.

It is the only periodic waveform that has this property. This property leads to its importance in Fourier analysis and makes it acoustically unique. This equation gives a sine wave for a single dimension; thus the generalized equation given above gives the displacement of the wave at a position x at time t along a single line.

This could, for example, be considered the value of a wave along a wire. In two or three spatial dimensions, the same equation describes a travelling plane wave if position x and wavenumber k are interpreted as vectors, and their product as a dot product.

For more complex waves such as the height of a water wave in a pond after a stone has been dropped in, more complex equations are needed.

This wave pattern occurs often in nature, including wind wavessound waves, and light waves. Because of this head startit is often said that the cosine function leads the sine function or the sine lags the cosine. The human ear can recognize single sine waves as sounding clear because sine waves are representations of a single frequency with no harmonics.

To the human ear, a sound that is made of more than one sine wave will have perceptible harmonics; addition of different sine waves results in a different waveform and thus changes the timbre of the sound. Presence of higher harmonics in addition to the fundamental causes variation in the timbre, which is the reason why the same musical note the same frequency played on different instruments sounds different.

On the other hand, if the sound contains aperiodic waves along with sine waves which are periodicthen the sound will be perceived to be noisy, as noise is characterized as being aperiodic or having a non-repetitive pattern.

InFrench mathematician Joseph Fourier discovered that sinusoidal waves can be used as simple building blocks to describe and approximate any periodic waveform, including square waves.

Fourier used it as an analytical tool in the study of waves and heat flow. It is frequently used in signal processing and the statistical analysis of time series.

Since sine waves propagate without changing form in distributed linear systems[ definition needed ] they are often used to analyze wave propagation.