Question

MATLAB Please fix the error. Thank you!!

Given the following piecewise function, f(x) Create a function M-file, PieceZig, that accepts one number as input, evaluates

Test 1 Pretest) Test 2 (Pretest) Test 3 (Pretest) Test 4 (Pretest) Test 5 (Pretest) Test 6 (Pretest) Test 7 (Pretest) Test 8

0 0
Add a comment Improve this question Transcribed image text
Answer #1
function fx = PieceZig(x)
    [r,c] = size(x)
    if(r>1 || c>1)
        fx = 0;
    else
        if(x<-5)
            fx = -5;
        elseif((-5 <= x)&&(x<=5))
            fx=x;
        elseif(x>5)
            fx=5;
        end
    end
end

Note: Please comment below if you have any doubts

Please up vote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
Please help! I'm really confused. Please answer question 1 with annual worth analysis and questio...
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
  • I'm working on the newton's method on matlab, could someone help me and show what two...

    I'm working on the newton's method on matlab, could someone help me and show what two lines are needed to be added in the codes in order to make this function work? function sample_newton(f, xc, tol, max_iter) % sample_newton(f, xc, tol, max_iter) % finds a root of the given function f over the interval [a, b] using Newton-Raphson method % IN: % f - the target function to find a root of % function handle with two outputs, f(x), f'(x)...

  • Please help code in c++ and use the answers you get from question 1 and 2...

    Please help code in c++ and use the answers you get from question 1 and 2 into the 3rd answer! Question 1 is first, question 2 is in the middle, question 3 is last Input Array (10 pts) te a function only (no main) that takes an array of doubles as a parameter as well as another integer rray. Create a for loop that asks the user to input any real number between-100 and r each element of the array....

  • MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts...

    MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts in order to get full credit. Help me out, thank you f LAB SECTION NAME HW6P3 (30 points) following are infinite series representations of the function, un pra i a script file HW6P3 that determines the value of the function from the sum of the series for a given value of x. The program (1 pt) must prompt the user to enter a value...

  • Need help on C++ (User-Defined Function) Format all numerical decimal values with 4 digits after ...

    need help on C++ (User-Defined Function) Format all numerical decimal values with 4 digits after the decimal point. Process and sample run: a) Function 1: A void function that uses parameters passed by reference representing the name of a data file to read data from, amount of principal in an investment portfolio, interest rate (any number such as 5.5 for 5.5% interest rate, etc.) , number of times the interest is compounded, and the number of years the money is...

  • Task 4 Many real world objects travel in a jagged manner that is best represented by piecewise fu...

    MATLAB question: Task 4 Many real world objects travel in a jagged manner that is best represented by piecewise functions. For example, the velocity of a rocket may change sharply when thrusters are enabled or disabled and due to various external factors. The velocity of a rocket can be modelled by v(t) where t represents the time 112-5t 0sts10 1100-5t10StS20 vt) 502( 20)25 20sIs 30 1520e0-30) 0 t >30 otherwise Write a function that takes a start and end time...

  • Please help with all four questions regarding LISP Programming. Thank you. Please answer all questions with...

    Please help with all four questions regarding LISP Programming. Thank you. Please answer all questions with output plesase. LISP Programming Assignment It is a good idea to start this assignment early; Lisp programming, while not inherently difficult, often seem somewhat foreign at first, particularly when it comes to recursion and list manipulation. This assignment is loosely based on material by Dr. Henri Casanova.   Problem #1 Define a function that takes two arguments and returns the greater of the two. Problem...

  • I'm a bit confused on how to get this program to run right. Here are the...

    I'm a bit confused on how to get this program to run right. Here are the directions: Part 1: Write a Python function called reduceWhitespace that is given a string line and returns the line with all extra whitespace characters between the words removed. For example, ‘This line has extra space characters ‘  ‘This line has extra space characters’ Function name: reduceWhitespace Number of parameters: one string line Return value: one string line The main file should handle the...

  • C++ please Possible algorithms – (1) use and modify the algorithm from program 2 if possible;...

    C++ please Possible algorithms – (1) use and modify the algorithm from program 2 if possible; (2) use unique value array; (3) use flag array (flags used to avoid counting a number more than 1 time); (4) compute frequency distribution (use unique and count arrays); (5) use count array to store the frequency of a number. No global variable are permitted in this assignment. Do not change the code provided only write the missing code. Write the missing C++ statements...

  • During lab 4, we have seen numerical implementation of Fourier Series for periodic signals. As first part of this assignment, you need to write a Matlab function that would take an array representing...

    During lab 4, we have seen numerical implementation of Fourier Series for periodic signals. As first part of this assignment, you need to write a Matlab function that would take an array representing a single period of a signal (x), corresponding time array (t), and return the Fourier Series coefficients (Ck) in exponential form. The function should also be able to take two (2) optional input arguments: number of Fourier coefficients (Nk) and plot option (p). Use the template ‘fourier_series_exp.m’...

  • The first programming project involves writing a program that computes the minimum, the maximum and the...

    The first programming project involves writing a program that computes the minimum, the maximum and the average weight of a collection of weights represented in pounds and ounces that are read from an input file. This program consists of two classes. The first class is the Weight class, which is specified in integer pounds and ounces stored as a double precision floating point number. It should have five public methods and two private methods: 1. A public constructor that allows...

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