When we’re working with real sinusoidal signals, we generally think in terms of signal frequency (in the analog domain) and sampling frequency (in the digital domain). If we want the plot to maintain this relationship between y and n, we can use the following command: The command y = sin(2*%pi*n/100) generates y values that correspond to the numbers in the array n. If we tell Scilab plot(y), it uses default values for the horizontal axis, and apparently these default values start at one. This occurs because we didn’t specify a list of horizontal-axis values that correspond to the vertical-axis values contained in the array y. In other words, the waveform is shifted one sample to the right. We know that sin(0) = 0, but in the plot, the waveform has a value of 0 for a horizontal-axis value of 1. There’s still something not quite right about the plot. In other words, the first cycle is covered by the 100 values from 0 to 99, the second cycle would be covered by the 100 values from 100 to 199, and so forth.) Here is the result: ( Note: I realize that in this case n does not extend to 100, but if it did, we would want the value 100 to be the first sample in the second cycle. Thus, we have reduced the argument range to 2π, and we are still producing 100 samples. You can readily confirm that this will work: if n is zero, the entire argument is zero if n is 100, the argument is (2π × 100/100) = 2π and all the numbers in between are scaled accordingly. The solution is to divide n by the desired number of samples per cycle, which in this case is 100, and also multiply it by 2π: The command y = sin(n) doesn’t produce the desired waveform because the argument given to the sine function is an array that extends from 0 to 99.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |