Question

Problem 3 In this problem you add some random noise to the sine function and then...

Problem 3 In this problem you add some random noise to the sine function and then calculate the derivative. • First, generate a vector (the same length as x, above) which consists of random numbers in the range (-0.02) to (0.02). Use the MATLAB function rand. rand will return a random number between 0 and 1. For this problem, you actually need random numbers between +/- 0.02. How will you convert the random numbers you obtain from rand to be within the correct range? To learn more about rand, type help rand in the Command Window. • In one figure window, plot sin(x) and sin(x) with added random noise on the same graph. • In the second figure window, plot the known (analytical) derivative, and the calculated derivative, using both the forward and central difference formulas, on the same graph. • In the third figure window, plot the error (difference between the calculated derivative and analytical derivative). Hand in: Your graphs for different methods and step sizes. Comment on the effects of method, step size and how the noise in your original (sine) function compares to the noise in the numerical derivative.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

As per the HomeworkLib policy on multipart questions, answer to first part is being given here:

As the x vector is not given in the context, we are assuming a sample x values here as:

%===================================================

clc;
clear all;

x = [0:pi/4:2*pi]; % Sample x values
f1 = sin(x);
noise = -0.2 + 0.4*rand(1,length(x));
f2 = sin(x)+noise;

figure
plot(x,f1,'-+');
hold on
plot(x,f2,'-o');
legend('Noiseless sin(x)','Noisy sin(x)');
xlabel('x');
ylabel('y');

%===================================================

Output:

Note: The output plot will be different for each run as the program will likely generate different random number on each run.

Add a comment
Know the answer?
Add Answer to:
Problem 3 In this problem you add some random noise to the sine function and then...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON:please display code in python Part 1: Determining the Values for a Sine Function Write a...

    PYTHON:please display code in python Part 1: Determining the Values for a Sine Function Write a Python program that displays and describes the equation for plotting the sine function, then prompts the user for the values A, B, C and D to be used in the calculation. Your program should then compute and display the values for Amplitude, Range, Frequency, Phase and Offset. Example input/output for part 1: Part 2: Displaying a Vertical Plot Header A vertical plot of the...

  • solve all questions simply by using matlab. write all step here please 1Normal 1 No Spac Heading1 Heading 2 DISCUSSION Solve all tasks given below: 1. Consider function f(x) 3.5-0.5x cos(6x) for...

    solve all questions simply by using matlab. write all step here please 1Normal 1 No Spac Heading1 Heading 2 DISCUSSION Solve all tasks given below: 1. Consider function f(x) 3.5-0.5x cos(6x) for the value of x between -2.0 until 4.0. Draw the plot in dash line and in red colour, Label the title and all axes. 2. Consider the following functions for 0sxS pi: x() 10e0.St sin(3t +2) y(t) 7e-04t cos(5t - 3) (a) Draw both graphs on the same...

  • The matlab code for the following problem is appreciated!! QUESTION 3 Write a function fnfr_plot that...

    The matlab code for the following problem is appreciated!! QUESTION 3 Write a function fnfr_plot that will receive two function handles from elementary math functions which accept a vector to first sort in ascending order then calculate. The script will display the results in two separate Figure Windows with the function names in the title. Submit: fnfr_plot.m Browse My Computer Attach File QUESTION 4 Generate 1x100 random vector, x in the range of 0<x<100 by using rand. Input 2 elementary...

  • Problem 1 (10 Marks) The noise X(t) applied to the filter shown in Figure I is...

    Problem 1 (10 Marks) The noise X(t) applied to the filter shown in Figure I is modeled as a WSS random process with PSD S,(f). Let Y(t) denote the random noise process at the output of the filter. A linea filsee Figure 1: The Filter. (T) Je Sinc 1. Find the frequency response, H(f), of the filter. 2. If X(t) is a white noise process with PSD No/2, find the PSD of the noise precess Y(t). 2- f 3. Is...

  • 3) Create a vector of noisy data by adding a trigonometric function to a random number,...

    3) Create a vector of noisy data by adding a trigonometric function to a random number, starting from your month of birth up to last 5 digits of your student ID number. So, a student with an ID number of 110030110 should create random numbers up to 30110. Calculate statistical values of the random data and print them to the command window in a tabular format. Smooth that noisy data with a moving average filter using a step size of...

  • matlab Problem 6: The Matlab command 'randn(m,n) produces an m x n matrix of random numbers...

    matlab Problem 6: The Matlab command 'randn(m,n) produces an m x n matrix of random numbers that are a realization of a white random process with some probability density function. Moreover, the Matlab command 'rand(m,n)' produces an mxn matrix of random numbers between 0 and 1 that are a realization of a white random process with some probability density function. a) Use Matlab to do the following steps: 1) Let u-randn (10000,1); and plot u. 2) Use the command 'mean(u)'...

  • Problem 4 : Finite difference formula and interpolation For this problem, you will approximate th...

    Please answer this problem using MATLAB. Problem 4 : Finite difference formula and interpolation For this problem, you will approximate the derivative of the function g(x)5x6x 23823x 15 on a set of points using the centered difference formula (x +h) -g(x- h) 2h g'(x) Then, you will find the interpolating polynomial through these points, Q, and verify that it is indeed close to the polynomial that is the true derivative of g, ie. Q(x) g'(x) 25x 24x36x+16x+3 In your prob40...

  • please code on MATHLAB and show graph thank you in advance! Generate the following function y1(t)=2*...

    please code on MATHLAB and show graph thank you in advance! Generate the following function y1(t)=2* sin (2*pi* 1 *t)+4*sin(2*pi*2*t)+3*sin(2*pi*4*t) y2(t)=2*cos(2*pi*1*t)+4*cos(2*pi*2*t)+3*cos(2*pi*4*t) First, required by sampling theorem, the step size of t (delta t) has to be smaller than a value. Figure out this value and set the delta t at least 3 times smaller than this value and calculated y1(t) and y2(t). Increase the step size (delta t) and recalculate y1(t) and y2(t). See the difference. Calculate Fourier Transform of...

  • Chapter 2.02: Problem #3 Using forward divided difference scheme, find the first derivative of the function f(x) - sin(...

    Chapter 2.02: Problem #3 Using forward divided difference scheme, find the first derivative of the function f(x) - sin(2x) at - x/3 correct within 3 significant digits. Start with a step size of h 0.01 and keep halving it till you find the answer. ее NOTE #1: The above mentioned problems are taken from the book: Numerical Methods with Applications, 2nd edition, by: A. Kaw& E. E. Kalu

  • 5 Random Numbers and Histograms [Applied] Let x = x1 + ... + x20, the sum...

    5 Random Numbers and Histograms [Applied] Let x = x1 + ... + x20, the sum of 20 independent Uniform(0,1) random variables. In R, create 1,000 simulations of x and plot their histogram. On the histogram, overlay a graph of the normal density function with the same mean as x. Comment on any differences between the histogram and the curve. Hint 1: To plot a histogram in R you can build on the following code: library(ggplot2) df <- data.frame( x...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT