Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

% 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions