ABCs_conditionals

ABCs_conditionals - % whether Y is...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [A B C D] = ABCs_conditionals(Z,Y,X) % ABCs of Cell Arrays % % This is a multi-part problem. Do each of the parts below. % % DO NOT CHANGE THE FUNCTION HEADER (the first line of code) % % a) IF statements. Z is a character. Fix the if statement below so that % it checks whether Z is an uppercase letter or a lowercase letter. If Z % is lowercase, set A to be the string 'lower'. Set A to 'upper' if Z is % uppercase. Set A to 'neither' if Z is not a letter. Replace every ? with % the necessary code. You MUST use the provided IF statement to receive % credit for this problem. % A = 'upper'; A = 'lower'; else A = 'neither'; end e % b) SWITCH statements. Y is a number between 0 and 10 inclusive and not % necesarily an integer. Fix the given switch statement so that it checks
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % whether Y is "odd", "even" or a "decimal". The switch should set B to % the string 'even','odd', or 'decimal' accordingly. Replace every ? with % the necessary code. You MUST use a SWITCH statement to receive credit % for this problem. switch mod(Y, 2) % change this line case 0 % change this line B = 'even'; case 1 % change this line B = 'odd'; otherwise B = 'decimal'; end e % c) any. X is a vector of logicals. Use the any( ) function to check if % any of the values of X is TRUE. Return a logical true or false % accordingly. Store your result in a variable named C. C = any(X);%fill in this line C % d) all. Use the all( ) function to check if all of the values of X % are TRUE. Return a logical true or false accordingly. Store your result % in a variable named D. D = all(X);%fill in this line...
View Full Document

Ask a homework question - tutors are online