Question: MATLAB QUESTION Loop + Conditional Statement Write a function called piecewise. It should take one input, an array of x values, and have one output,

MATLAB QUESTION Loop + Conditional Statement

Write a function called piecewise. It should take one input, an array of x values, and have one output, an array of y values.

It should implement the following piecewise function on all x values:

When x <= -1, y = log(abs(x))

When -1 < x < 0, y = abs(x)

When 1 > x >= 0,y = x

When x >= 1. y = log(x)

Where log is the natural log.

Assume that x and y are row arrays.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!