Question

2) (USE MATLAB) Create a function called g that satisfies the following criteria. (Hint: Find function)...

2) (USE MATLAB) Create a function called g that satisfies the following criteria. (Hint: Find function)

For x < -π                    g(x) = -1

For x ≥ -π and x ≤ π    g(x) = cos(x)

For x >π                      g(x) = -1

Plot your results for values of x from -2p to +2p. Choose your spacing to create a smooth curve.

Homework Answers

Answer #1

Matlab Code:

clc;

x = -2*pi:pi/100:-pi;

g = (-1).*x.^(0);

plot(x,g)

hold on

x = -pi:pi/100:pi;

g = cos(x);

plot(x,g)

hold on

x = pi:pi/100:2*pi;

g = (-1).*x.^(0);

plot(x,g)

set(gca,'XTick',-2*pi:pi:2*pi);

set(gca,'XTickLabel',{'-2*pi','-pi','0','pi','2*pi'});

xlabel('x')

ylabel('g(x)')

grid on

Plot:

if you have any doubt please ask in the comment box.

please do like and rate it nicely.

thank you.

Know the answer?
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
Similar Questions
Use Matlab to solve the following (a) Create a plot with a sphere at the center...
Use Matlab to solve the following (a) Create a plot with a sphere at the center of the graph (origin) representing the sun with a radius of 6955000 km. Make sure that the outside of the sphere is painted in ’autumn’ colors. (Hint: look up the sphere() function, the colormap() function, and the surf() function). (b) Create a variable t ranging from 0 to 2? with increments of 0.01. (c) The following Table gives you important values needed to compute...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads data from a file and performs regression analysis using polyfit and polyval. The function shall have the following features: The input arguments shall include the file name (string), a vector of integers for the degrees of polynomial fits to be determined, and an optional plot type specifier (‘m’ for multiple plots, ‘s’ for a single plot - default). The data files will be text...
Using MATLAB The range of an object shot at an angle θ (with respect to x-axis),...
Using MATLAB The range of an object shot at an angle θ (with respect to x-axis), with the initial velocity of V0 (in the absence of air resistance), is calculated by the following formula: range=(Vo^2/g)(sin(2theta)) where (0<=theta<=pi/2) And the trajectory of object is given by:     h=tan(theta).x-(g/2Vo^2*cos^2(theta)).x^2 .Where h is the height of the object at each x location and g = 9.81 m/s2. a) Using π/8 increment size for the angle and V0 = 10 m/s, plot the trajectories of...
Matlab Create plot of the following density functions using x values between -10 and 10 with...
Matlab Create plot of the following density functions using x values between -10 and 10 with an increment of 0.02 -Normal cumulative distribution function with mu=1, sigma=1, mu=0, sigma=2, mu=0,sigma=1/2
"Allowed to use any platform" > Octave desktop app, Octave Online, MATLAB App, or MATLAB Online....
"Allowed to use any platform" > Octave desktop app, Octave Online, MATLAB App, or MATLAB Online. Create a script or a function to solve the following problem. The irrational number π can be (indirectly) approximated by an infinite series, that is π4=1-13+15-17+… The script or function should feature the following: the user can input the number of terms of the infinite series n , compute the sum of n terms of the infinite series, compute the absolute difference (error) of...
14. Practice questions a. Create an anonymous function called func1 for the dummy argument x that...
14. Practice questions a. Create an anonymous function called func1 for the dummy argument x that finds the exponential of the negative one-half times the argument, and multiplies it by the sine of five times the argument. If given a vector or matrix, the function should perform element-by-element processing. b. Using plot(), plot plotr -vs- func1(plotr) as a blue line. Then plot this same function again over the same range (0, 5) as a dashed red line using fplot(), keeping...
A)Determine if the function g(x) = 2(x^14)^1/15 satisfies the mean value theorem over the interval [-70,70]...
A)Determine if the function g(x) = 2(x^14)^1/15 satisfies the mean value theorem over the interval [-70,70] B) Find and classify all extrema and inflection points of f(x) = cos^4(x) over the interval (-6,6). C) Determine 2 real numbers with difference of 70 and maximum product.
Write a MATLAB m file to plot the 3-D curve represented by a multivariable function z(x,y)...
Write a MATLAB m file to plot the 3-D curve represented by a multivariable function z(x,y) = x2 −0.5y2 over x ∈ [−2,2] and y ∈ [−2,2]. Use a 2 point thickness. For both x an y axes, choose the grid size to be 0.05. Clearly label and title your plot. Rotate the view at an azymuth of −20 , and elevation of 20 . You need to use the following commands: x=-2:0.05:2; y=x; z=x.^2-0.5*y.^2; plot3(x,y,z,’LineWidth’,2) label(’ My 3D curve’);...
Question 4 MATLAB a) Write a function file called q4.m containing the following nonlinear equations. ?(?1?2...
Question 4 MATLAB a) Write a function file called q4.m containing the following nonlinear equations. ?(?1?2 ) = ?1 2 + ?2 2 − 26 ?(?1?2 ) = 3?1 2 + 25?2 2 − 100 (1 Mark) b) Use MATLAB’s FSOLVE operator to solve these equations with x1 = 2 and x2 = 2 as your starting point. How many iterations did MATLAB use to solve them? (1 Mark)
2. 2052 Write a function in MATLAB called HTBALL to calculate the height of a ball...
2. 2052 Write a function in MATLAB called HTBALL to calculate the height of a ball based on a single input, the elapsed time. The elapsed time will be a single variable in the range of 0 to 6. Predict the value by fitting a 2nd order polynominal to the data points shown below using the polyfit command. Use the command polyval to determine the height of the ball at the inputted time. timevals=[0,.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6]; height=[0,46,84,114,136,150,156,154,144,126,100,66,24]; Copy and paste the data...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT