Question: % Function Description: Compute Piecewise Function % ---Inputs--- % Input1: x - Number to generate % ---Outputs--- % Output1: x1 - valuse for x 2

% Function Description: Compute Piecewise Function % ---Inputs--- % Input1: x - Number to generate % ---Outputs--- % Output1: x1 - valuse for x<=2 % Output2: x2 - value for x > 2

%% Piecewise functions x1 = find(x<=2); f1 = 2.*x(x1); x2 = find(x>2); f2 = x(x2).^2; fx = [f1,f2]; end

x = -3:0.5:5; f = f(x); plot(x,f(x)) xlabel('x') ylabel('f(x)')

array indices must be positive integers or logical variables?

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!