- #1
gfd43tg
Gold Member
- 950
- 50
Homework Statement
#1 in the attachment
Homework Equations
The Attempt at a Solution
My code is working for all of the numeric, logical, character portions. I got 7/8 points
Code:
if ischar(X_input)
Y_output = upper(X_input);
elseif isnumeric(X_input)
switch isnumeric(X_input)
case X_input < -2
Y_output = -1./((X_input.^2) + 1);
case (-2 <= X_input) & (X_input < -1)
Y_output = sin(X_input);
case (-1 <= X_input) & (X_input < 1)
Y_output = X_input.^2;
case (1 <= X_input) & (X_input < 2)
Y_output = 2;
case X_input >= 2
Y_output = 1./(X_input + 1);
end
elseif islogical(X_input)
Y_output = logical(~X_input);
else
Y_output = NaN;
end