Question

In: Computer Science

Example 2: Now suppose we want to plot one period of this periodic sine function: We...

Example 2:
Now suppose we want to plot one period of this periodic sine function:

We could try to remember the rules for the shape of sine curves based on the general format y=d+sin(bx+c). This is best, but do you remember? What we can do without having to remember

is to plot this formula over a few different viewing windows until we can figure it out. Here is an example with comments

Figure 2: Different viewing windows to frame one period of a sine function.

>> x=linspace(0,2*pi);  plot(x,50+30*sin(2*pi*x/365))                    %% [0,2pi] is always a good start, but it is too small. Try a larger domain  
>> x=linspace(0,100);  plot(x,50+30*sin(2*pi*x/365))                    %% Still too small. Be bold let's see try 1000  
>> x=linspace(0,1000);  plot(x,50+30*sin(2*pi*x/365))                  %% Oops, too big now  
>> x=linspace(0,365);  plot(x,50+30*sin(2*pi*x/365))                    %% just right. Oh yeah T=(2*pi/b)!    

That doesn't take too long, as we only need to change one number and rerun the line. To take advantage of the "up arrow" trick, we put the commands on one line and combined the function evaluation with the plot function.

Exercise 3a:
Find the suggested values by plotting the graphs until you can figure out the answer.

  1. Repeating the above example, find one period of the function

(This is a bit tricky! Keep plotting until you clearly get one period shown in the viewing window.)

Solutions

Expert Solution

Script:

clc;close all;clear all;

figure;

d=1;b=2*pi/20;c=0.5;

subplot(321)

x=linspace(0,500); plot(x,d+30*sin((b*x)+c));grid;

xlabel('t');ylabel('x(t)')

subplot(322)

x=linspace(0,100); plot(x,d+30*sin((b*x)+c));grid;

xlabel('t');ylabel('x(t)')

subplot(323)

x=linspace(0,50); plot(x,d+30*sin((b*x)+c)) ;grid;

xlabel('t');ylabel('x(t)')

subplot(324)

x=linspace(0,25); plot(x,d+30*sin((b*x)+c));grid;

xlabel('t');ylabel('x(t)')

subplot(325)

x=linspace(0,20); plot(x,d+30*sin((b*x)+c));grid;

xlabel('t');ylabel('x(t)')

title('x(t) for one period by evaluating the above 4 plots')

figure;

T=2*pi/b;

x=linspace(0,T); plot(x,d+30*sin((b*x)+c)) ;grid;

xlabel('t');ylabel('x(t)');title('x(t) for one period exactly from the formulae')


Related Solutions

class : Analysis Real Ques : give 2 example periodic function and show the periodic function...
class : Analysis Real Ques : give 2 example periodic function and show the periodic function is uniform contiunity
Identify the Fourier series for the half-wave rectified sine function with period 2π. This is the...
Identify the Fourier series for the half-wave rectified sine function with period 2π. This is the function that is sin(x) when sin(x) is positive, and zero when sin(x) is negative
We want to save $120,000 now and $150,000 one year from now for possible replacement of...
We want to save $120,000 now and $150,000 one year from now for possible replacement of the old computer. If the replacement will occur at the end of 5 years from now. How much will we have in the account, given the interest rate is 10% per year? Your answer should include the cash flow diagram, the related factors, such as (P/F,i%,n), and the final answer. The calculation should be done manually and also by EXCEL. You may insert the...
2. What is meant when we say that we want to “Map” a function on a...
2. What is meant when we say that we want to “Map” a function on a list of values? Illustrate with an example. (We are talking about big data)
A periodic function f(t) of period T=2π is defined as f(t)=2t ^2 over the period -π<t<π...
A periodic function f(t) of period T=2π is defined as f(t)=2t ^2 over the period -π<t<π i) Sketch the function over the interval -3π<t<3π ii) Find the circular frequency w(omega) and the symmetry of the function (odd, even or neither). iii) Determine the trigonometric Fourier coefficients for the function f(t) iv) Write down its Fourier series for n=0, 1, 2, 3 where n is the harmonic number. v) Determine the Fourier series for the function g(t)=2t^ 2 -1 over the...
Problem 18. Suppose we want to maximize the utility function u = x2y subject to the...
Problem 18. Suppose we want to maximize the utility function u = x2y subject to the following two constraints: x + y ≤ 100 and 2x + 8y ≤ 240. Also, x and y must be greater than or equal to 0. Write the Lagrangian function L. Write the Kuhn-Tucker conditions for this problem. Use trial and error to solve for the optimal values of x and y. What are the values of the Lagrange multipliers at the optimal solution?....
Suppose we have 6 distinct items and we want to place 4 in one bin and...
Suppose we have 6 distinct items and we want to place 4 in one bin and 2 in the other. How many ways can this be done if order does not matter? (answer is 15)
Going back to the example from question 3, suppose we now decide to look at similar...
Going back to the example from question 3, suppose we now decide to look at similar data but compare men and women’s drinking habits. What is the 99% confidence interval for the difference between the average for men and women? What is the test statistic for the difference from men to women? What is the p-value? Gender Men Women Sample Size 20 22 Average Drinks Per Week 10.5 4.7 Sample Standard Deviation 11.7 4.8
USING EXCEL Now your task is to plot the cumulative probability density function with the information...
USING EXCEL Now your task is to plot the cumulative probability density function with the information given in number 2. First, open Worksheet #3. Then enter “=” in cell A17 of your new worksheet and then click on cell A17 of your second worksheet and hit return. Then copy cell A17 down the A column as before.               Next, you’re to compute the cumulative probabilities for x = 0, 1, 2, …. 20, beginning in cell B17 and ending in...
Suppose prices in period one (base period) are (1, 2) and the consumer chooses (5.00, 6.00)....
Suppose prices in period one (base period) are (1, 2) and the consumer chooses (5.00, 6.00). In period two (current period), prices are (3.00, 4.00) and the consumer updates his optimal consumption bundle and chooses (2, 2). The Paasche price index of prices in period two relative to period one is _____ . (Round to two decimal places if necessary.)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT