The complete required code:
# input
x.values <- seq(-2, 2, by = 0.1)
# for each x calculate y
n <- length(x.values)
y.values <- rep(0,n)
for(i in 1:n){
x <-x.values[i]
if(x <= 0){
y <- -(x^3)
}
if( x > 0 && x <=1){
y <- x^2
}
if(x >1){
y <- sqrt(x)
}
y.values[i] <-y
}
# output
plot(x.values, y.values, type="l")
1. Consider the function y - f(x) defined by Supposing that you are given x, write...
1. Consider the function y f(x) defined by Supposing that you are given x, write an R expression for y using if state- ments Add your expression for y to the following program, then run it to plot the function f. # input x,values <-seq(-2, 2, by 0.1) # for each x calculate y n <- length(x.values) y.values <- rep(0, n) for (i in 1 :n) x <- x. values[i] # your expression for y goes here y.values ij <-...
1. Consider the function y f(x) defined by Supposing that you are given x, write an R expression for y using if state- ments Add your expression for y to the following program, then run it to plot the function f. # input x,values <-seq(-2, 2, by 0.1) # for each x calculate y n <- length(x.values) y.values <- rep(0, n) for (i in 1 :n) x <- x. values[i] # your expression for y goes here y.values ij <-...
Question 1: Creating a user-defined function Write a user-defined MATLAB function named PBTask4pl_f.m for the following math function with x the input argument and y the output y(x)=0.8x4-13x2-5x The function should work for x being a scalar or a vector. Write a script file named PBTask4pl.m to a) Use the function to calculate y(3) and y(5) and display the results in command window b) Use the function to make a plot of the function y(x) for -5:5: x 5:5. Label...
Consider the function f : {0,1} » N → NU{0} defined as f(x,y) = (-1)22 y. Is f injective? Surjective? Explain your answer.
Write a user-defined MATLAB function for the following math function y(x). The input to the function is x and the output is y. y(x)=-(0.2*x^4)+((e^-0.5*x)*x^3)+7*x^2 Call the function to calculate y(x) over the interval -3 ≤ x ≤ 4 for each increment of 1. Display x and corresponding y(x) in a text file with labeled column headings. Use the type command to display the contents in the text file.
Question 6 14 pts Consider the curve C defined by the parametric equations: x f(t) y= g(t) = sint -t costt (d) Which picture shows the curve C? Recall the curve C is defined by : x= f(t) cos t g(t) = sint - t y 20 20 10 10F 0 -10 -10 -20 -20 -20 10 -20 10 C 20 -10 0 10 (i) (ii) X 20 20 10 10 0 0 10 -10 -20 -20h -20 10 -20...
for the plot, provide the matlab code. 3. Let the input signal x[n] (defined for -<n < oo) to the system be x[n] = 3 cos( 0.05πn) + 4 cos( 0.45πn) + cos( 0.95 n) and the transfer function be 1-re-je a) Plot this signal as a function of n. b) Determine and plot the output y[n] produced by the system due to the input analyzed in part a) of this problem. Do this first with r 0.05 and then...
Problem 2: Create a surface plot and a contour plot of the function f(x, y) = xe-I(x-y2)*+y?] Where -2 x 2 and -2 < y s 2. Use a step size of 0.1. Add labels to the axis Problem 2: Create a surface plot and a contour plot of the function f(x, y) = xe-I(x-y2)*+y?] Where -2 x 2 and -2
Let X and Y be two continuous random variables whose probability density function joint is defined as follows: f(X,Y) (x,y) = cy2 I(0.2) (x) I(0.1) (y).
48 The function f is defined by f(x) = for 3 <x< 7. The function g is defined by g(x) = 2x - 4 for .X-1 a<x<b, where a and b are constants. (i) Find the greatest value of a and the least value of b which will permit the formation of the composite function gf. [2] It is now given that the conditions for the formation of gf are satisfied. (ii) Find an expression for gf(x). [1] (iii) Find...