Question

In: Mechanical Engineering

Write a script le using conditional statements to evaluate the following function, assuming that the scalar variable x has a value. The function is Y = ex+1 fo

Write a script le using conditional statements to evaluate the following function, assuming that the scalar variable x has a value. The function is

Y = ex+1 for x < -1, y = 2 + cos(πx) for -1 ≤ x ≤ 5, and y = 10(x - 5) + 1 for x ≥ 5. Use your le to evaluate y for x = -5, x = 3, and x = 15, and check the results by hand.

Solutions

Expert Solution

Matlab script file for following function is to evaluate x = -5

x = -5;

if x < -1

y = exp(x + 1);

elseif x < 5

y = 2 + cos(pi*x);

else

y = 10*(x - 5) + 1;

end

 

Output: y = 0.0183

 

Matlab script file for following function is to evaluate x = 3

x = 3;

if x < -1

y = exp(x + 1);

elseif x < 5

y = 2 + cos(pi*x);

else

y = 10*(x - 5) + 1;

end

 

output: y = 1

 

Matlab script file for following function is to evaluate x = -15

x = -15;

if x < -1

y = exp(x + 1);

elseif x < 5

y = 2 + cos(pi*x);

else

y = 10*(x - 5) + 1;

end

 

output: y = 101


Output: y = 0.0183

output: y = 1

 

Related Solutions

Write a script that will first initialize a string variable that will store x and y...
Write a script that will first initialize a string variable that will store x and y coordinates of a point in the form ‘x 3.1 y 6.4’. Then, use string manipulating functions to extract the coordinates and plot them. ANS % create a string variable of the form 'x 3.1 y 6.4' % extract the x and y coordinates and plot str = 'x 2.3 y 4.5'; [letter rest] = strtok(str); [x rest] = strtok(rest); [letter rest] = strtok(rest); y...
An economy has the following Cobb-Douglas production function: Y = Ka(LE)1-a The economy has a capital...
An economy has the following Cobb-Douglas production function: Y = Ka(LE)1-a The economy has a capital share of 1/3, a saving rate of 24 percent, a depreciation rate of 3 percent, a rate of population growth of 2 percent, and a rate of labor-augmenting technological change of 1 percent. It is in steady state. a. What is the steady-state growth rate in total output? b.  What is the steady-state growth rate in output per worker? c.  What is the steady-state growth rate...
1. Using the following table of relation between X & Y (Y is the independent Variable):...
1. Using the following table of relation between X & Y (Y is the independent Variable): xi -2 2 4 5 4 6 7 8 11 yi -4 1 3 1 3 8 10 20 30 a. Find the estimated regression equation. Show ALL your calculations and the appropriate formula. WRITE Formula in all the questions below and substitute for the numbers, demonstrate your work. b. Calculate R2. Comment on the Goodness of the Fit. Is it a good fit?...
A random variable Y is a function of random variable X, where y=x^2 and fx(x)=(x+1)/2 from...
A random variable Y is a function of random variable X, where y=x^2 and fx(x)=(x+1)/2 from -1 to 1 and =0 elsewhere. Determine fy(y). In this problem, there are two x values for every y value, which means x=T^-1(y)= +y^0.5 and -y^0.5. Be sure you account for both of these. Ans: fy(y)=0.5y^-0.5
Using Python write a function that implements the following two-dimensional objective function: F (x, y) =...
Using Python write a function that implements the following two-dimensional objective function: F (x, y) = (x^2 + y − 11)^2 + (x + y^2 − 7 )^22 . Determine how many local minimums and maximums and their location for this objective function.
Write a MATLAB script file that will give the value of f(x) using method of least...
Write a MATLAB script file that will give the value of f(x) using method of least squares and asks the user to enter values of x, y, n (curve fit), and x for f(x).
Write a MATLAB script file that will give the value of f(x) using method of least...
Write a MATLAB script file that will give the value of f(x) using method of least squares and asks the user to enter values of x, y, n (linear, quadratic, or cubic), and x for f(x).
Let X and Y have the following joint density function f(x,y)=k(1-y) , 0≤x≤y≤1. Find the value...
Let X and Y have the following joint density function f(x,y)=k(1-y) , 0≤x≤y≤1. Find the value of k that makes this a probability density function. Compute the probability that P(X≤3/4, Y≥1/2). Find E(X). Find E(X|Y=y).
Using the conditional assignment statements, write the verilog code for 16:1 Mux. Write the test bench...
Using the conditional assignment statements, write the verilog code for 16:1 Mux. Write the test bench for this module.
Write the following Python script: Problem Statement A string X is an anagram of string Y...
Write the following Python script: Problem Statement A string X is an anagram of string Y if X can be obtained by arranging all characters of Y in some order, without removing any characters and without adding new characters. For example, each of the strings "baba", "abab", "aabb" and "abba" is an anagram of "aabb", and strings "aaab", "aab" and "aabc" are not anagrams of "aabb". A set of strings is anagram-free if it contains no pair of strings which...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT