Cody

Solution 110531

Submitted on 11 Jul 2012
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, log in.

Test Suite

Test Status Code Input and Output
1   Pass
%% fcn = 'help'; sfcn = {'doc','docsearch','lookfor','matlabpath','which'}; assert(isequal(seeAlso(fcn),sfcn))
t = HELP Display help text in Command Window. HELP, by itself, lists all primary help topics. Each primary topic corresponds to a folder name on the MATLAB search path. HELP NAME displays the help for the functionality specified by NAME, such as a function, operator symbol, method, class, or toolbox. NAME can include a partial path. Some classes require that you specify the package name. Events, properties, and some methods require that you specify the class name. Separate the components of the name with periods, using one of the following forms: HELP CLASSNAME.NAME HELP PACKAGENAME.CLASSNAME HELP PACKAGENAME.CLASSNAME.NAME If NAME is the name of both a folder and a function, HELP displays help for both the folder and the function. The help for a folder is usually a list of the program files in that folder. If NAME appears in multiple folders on the MATLAB path, HELP displays information about the first instance of NAME found on the path. NOTE: In the help, some function names are capitalized to make them stand out. In practice, type function names in lowercase. For functions that are shown with mixed case (such as javaObject), type the mixed case as shown. EXAMPLES: help close % help for the CLOSE function help database/close % help for CLOSE in the Database Toolbox help database % list of functions in the Database Toolbox % and help for the DATABASE function help containers.Map.isKey % help for isKey method See also DOC, DOCSEARCH, LOOKFOR, MATLABPATH, WHICH. Overloaded methods: fdesign.help cvtest/help cvdata/help Reference page in Help browser doc help q = 1682 r = DOC, DOCSEARCH, LOOKFOR, MATLABPATH, WHICH. Overloaded methods: fdesign.help cvtest/help cvdata/help Reference page in Help browser doc help r = DOC, DOCSEARCH, LOOKFOR, MATLABPATH, WHICH sfcn = 'doc' 'docsearch' 'lookfor' 'matlabpath' 'which'
2   Pass
%% fcn = 'regexp'; sfcn = {'regexpi','regexprep','regexptranslate','strcmp','strfind'}; assert(isequal(seeAlso(fcn),sfcn))
t = REGEXP Match regular expression. S = REGEXP(STRING,EXPRESSION) matches the regular expression, EXPRESSION, in the string, STRING. The indices of the beginning of the matches are returned. In EXPRESSION, patterns are specified using combinations of metacharacters and literal characters. There are a few classes of metacharacters, partially listed below. More extensive explanation can be found in the Regular Expressions section of the MATLAB documentation. The following metacharacters match exactly one character from its respective set of characters: Metacharacter Meaning --------------- -------------------------------- . Any character [] Any character contained within the brackets [^] Any character not contained within the brackets \w A word character [a-z_A-Z0-9] \W Not a word character [^a-z_A-Z0-9] \d A digit [0-9] \D Not a digit [^0-9] \s Whitespace [ \t\r\n\f\v] \S Not whitespace [^ \t\r\n\f\v] The following metacharacters are used to logically group subexpressions or to specify context for a position in the match. These metacharacters do not match any characters in the string: Metacharacter Meaning --------------- -------------------------------- () Group subexpression | Match subexpression before or after the | ^ Match expression at the start of string $ Match expression at the end of string \< Match expression at the start of a word \> Match expression at the end of a word The following metacharacters specify the number of times the previous metacharacter or grouped subexpression may be matched: Metacharacter Meaning --------------- -------------------------------- * Match zero or more occurrences + Match one or more occurrences ? Match zero or one occurrence {n,m} Match between n and m occurrences Characters that are not special metacharacters are all treated literally in a match. To match a character that is a special metacharacter, escape that character with a '\'. For example '.' matches any character, so to match a '.' specifically, use '\.' in your pattern. Example: str = 'bat cat can car coat court cut ct caoueouat'; pat = 'c[aeiou]+t'; regexp(str, pat) returns [5 17 28 35] When one of STRING or EXPRESSION is a cell array of strings, REGEXP matches the string input with each element of the cell array input. Example: str = {'Madrid, Spain' 'Romeo and Juliet' 'MATLAB is great'}; pat = '\s'; regexp(str, pat) returns {[8]; [6 10]; [7 10]} When both STRING and EXPRESSION are cell arrays of strings, REGEXP matches the elements of STRING and EXPRESSION sequentially. The number of elements in STRING and EXPRESSION must be identical. Example: str = {'Madrid, Spain' 'Romeo and Juliet' 'MATLAB is great'}; pat = {'\s', '\w+', '[A-Z]'}; regexp(str, pat) returns {[8]; [1 7 11]; [1 2 3 4 5 6]} REGEXP supports up to six outputs. These outputs may be requested individually or in combinations by using additional input keywords. The order of the input keywords corresponds to the order of the results. The input keywords and their corresponding results in the default order are: Keyword Result --------------- -------------------------------- 'start' Row vector of starting indices of each match 'end' Row vector of ending indices of each match 'tokenExtents' Cell array of extents of tokens in each match 'match' Cell array of the text of each match 'tokens' Cell array of the text of each token in each match 'names' Structure array of each named token in each match 'split' Cell array of the text delimited by each match Example: str = 'regexp helps you relax'; pat = '\w*x\w*'; m = regexp(str, pat, 'match') returns m = {'regexp', 'relax'} Example: str = 'regexp helps you relax'; pat = '\s+'; s = regexp(str, pat, 'split') returns s = {'regexp', 'helps', 'you', 'relax'} Tokens are created by parenthesized subexpressions within EXPRESSION. Example: str = 'six sides of a hexagon'; pat = 's(\w*)s'; t = regexp(str, pat, 'tokens') returns t = {{'ide'}} Named tokens are denoted by the pattern (?<name>...). The 'names' result structure will have fields corresponding to the named tokens in EXPRESSION. Example: str = 'John Davis; Rogers, James'; pat = '(?<first>\w+)\s+(?<last>\w+)|(?<last>\w+),\s+(?<first>\w+)'; n = regexp(str, pat, 'names') returns n(1).first = 'John' n(1).last = 'Davis' n(2).first = 'James' n(2).last = 'Rogers' By default, REGEXP returns all matches. To find just the first match, use REGEXP(STRING,EXPRESSION,'once'). REGEXP supports international character sets. See also REGEXPI, REGEXPREP, REGEXPTRANSLATE, STRCMP, STRFIND. Reference page in Help browser doc regexp q = 5479 r = REGEXPI, REGEXPREP, REGEXPTRANSLATE, STRCMP, STRFIND. Reference page in Help browser doc regexp r = REGEXPI, REGEXPREP, REGEXPTRANSLATE, STRCMP, STRFIND sfcn = 'regexpi' 'regexprep' 'regexptranslate' 'strcmp' 'strfind'
3   Pass
%% fcn = 'why'; sfcn = {}; assert(isequal(seeAlso(fcn),sfcn))
t = WHY Provides succinct answers to almost any question. WHY, by itself, provides a random answer. WHY(N) provides the N-th answer. Please embellish or modify this function to suit your own tastes. q = []
4   Pass
%% fcn = 'who'; sfcn = {'whos','clear','clearvars','save','load'}; assert(isequal(seeAlso(fcn),sfcn))
t = WHO List current variables. WHO lists the variables in the current workspace. In a nested function, variables are grouped into those in the nested function and those in each of the containing functions. WHO displays only the variables names, not the function to which each variable belongs. For this information, use WHOS. In nested functions and in functions containing nested functions, even unassigned variables are listed. WHOS lists more information about each variable. WHO GLOBAL and WHOS GLOBAL list the variables in the global workspace. WHO -FILE FILENAME lists the variables in the specified .MAT file. WHO ... VAR1 VAR2 restricts the display to the variables specified. The wildcard character '*' can be used to display variables that match a pattern. For instance, WHO A* finds all variables in the current workspace that start with A. WHO -REGEXP PAT1 PAT2 can be used to display all variables matching the specified patterns using regular expressions. For more information on using regular expressions, type "doc regexp" at the command prompt. Use the functional form of WHO, such as WHO('-file',FILE,V1,V2), when the filename or variable names are stored in strings. S = WHO(...) returns a cell array containing the names of the variables in the workspace or file. You must use the functional form of WHO when there is an output argument. Examples for pattern matching: who a* % Show variable names starting with "a" who -regexp ^b\d{3}$ % Show variable names starting with "b" % and followed by 3 digits who -file fname -regexp \d % Show variable names containing any % digits that exist in MAT-file fname See also WHOS, CLEAR, CLEARVARS, SAVE, LOAD. Overloaded methods: Simulink.who Reference page in Help browser doc who q = 1874 r = WHOS, CLEAR, CLEARVARS, SAVE, LOAD. Overloaded methods: Simulink.who Reference page in Help browser doc who r = WHOS, CLEAR, CLEARVARS, SAVE, LOAD sfcn = 'whos' 'clear' 'clearvars' 'save' 'load'
5   Pass
%% fcn = 'which'; sfcn = {'dir','help','who','what','exist','lookfor'}; assert(isequal(seeAlso(fcn),sfcn))
t = WHICH Locate functions and files. WHICH FUN displays the full pathname of the function with the name FUN. If FUN is something other than a function (a variable in the workspace, a loaded Simulink model, a method of a Java class on the classpath), then WHICH displays a message identifying it as such. If FUN is a filename, including extension, then WHICH displays the full pathname of that file. WHICH FUN -ALL displays the paths to all functions with the name FUN. The first function displayed has precedence over all other functions that are displayed. The relative order of the subset of functions marked as Shadowed should not be relied on. See FUNCTION PRECEDENCE, below. You can use -ALL with any syntax for WHICH. WHICH FUN(A,B,...) shows which implementation of function FUN would be invoked if you were to call FUN with input arguments A, B, etc. Use this syntax for overloaded functions. WHICH FUN1 IN FUN2 displays the pathname to function FUN1 in the context of program file FUN2. While debugging FUN2, WHICH FUN1 does the same thing. You can use this to determine if a subfunction is being called instead of a function on the path. S = WHICH(...) returns the results of WHICH in the string S. (If WHICH is called on a variable, then S is the string 'variable'.) C = WHICH(...,'-ALL') returns the results of the multiple search version of WHICH in the cell array C. Each row of cell array C identifies a function and the functions are in order of precedence. FUNCTION PRECEDENCE: WHICH and WHICH -ALL expose the precedence rules used by MATLAB to determine which implementation of a multiply-defined function to dispatch to. MATLAB function precedence rules are described in the MATLAB Programming documentation. See also DIR, HELP, WHO, WHAT, EXIST, LOOKFOR. Reference page in Help browser doc which q = 1879 r = DIR, HELP, WHO, WHAT, EXIST, LOOKFOR. Reference page in Help browser doc which r = DIR, HELP, WHO, WHAT, EXIST, LOOKFOR sfcn = 'dir' 'help' 'who' 'what' 'exist' 'lookfor'
6   Pass
%% fcn = 'what'; sfcn = {'dir','who','which','lookfor'}; assert(isequal(seeAlso(fcn),sfcn))
t = WHAT List MATLAB-specific files in directory. The command WHAT, by itself, lists the MATLAB specific files found in the current working directory. Most data files and other non-MATLAB files are not listed. Use DIR to get a list of everything. The command WHAT DIRNAME lists the files in directory dirname on the MATLABPATH. It is not necessary to give the full path name of the directory; a MATLABPATH relative partial pathname can be specified instead (see PARTIALPATH). For example, "what general" and "what matlab/general" both list the MATLAB program files in directory toolbox/matlab/general. W = WHAT('directory') returns the results of WHAT in a structure array with the fields: path -- path to directory m -- cell array of MATLAB program file names. mat -- cell array of mat-file names. mex -- cell array of mex-file names. mdl -- cell array of mdl-file names. slx -- cell array of slx-file names. p -- cell array of p-file names. classes -- cell array of class directory names. packages -- cell array of package directory names. See also DIR, WHO, WHICH, LOOKFOR. Reference page in Help browser doc what q = 1209 r = DIR, WHO, WHICH, LOOKFOR. Reference page in Help browser doc what r = DIR, WHO, WHICH, LOOKFOR sfcn = 'dir' 'who' 'which' 'lookfor'
7   Pass
%% fcn = 'sumabs'; sfcn = {'meanabs','sumsqr','meansqr'}; assert(isequal(seeAlso(fcn),sfcn))
t = SUMABS Sum of absolute elements of a matrix or matrices. [S,N] = sumabs(X) returns S the sum of all squared finite elements in M, and the number of finite elements N. M may be a numeric matrix or a cell array of numeric matrices. For example: s = sumabs([1 2;3 4]) [s,n] = sumabs({[1 2; NaN 4], [4 5; 2 3]}) See also MEANABS, SUMSQR, MEANSQR. Reference page in Help browser doc sumabs q = 440 r = MEANABS, SUMSQR, MEANSQR. Reference page in Help browser doc sumabs r = MEANABS, SUMSQR, MEANSQR sfcn = 'meanabs' 'sumsqr' 'meansqr'
8   Fail
%% fcn = 'bsxfun'; sfcn = {'repmat','arrayfun'}; assert(isequal(seeAlso(fcn),sfcn))
Error: Assertion failed.
9   Fail
%% fcn = 'mat2cell'; sfcn = {'cell2mat','num2cell'}; assert(isequal(seeAlso(fcn),sfcn))
Error: Assertion failed.
10   Fail
%% fcn = 'cell2mat'; sfcn = {'mat2cell','num2cell'}; assert(isequal(seeAlso(fcn),sfcn))
Error: Assertion failed.
11   Pass
%% fcn = 'cumprod'; sfcn = {'cumsum','sum','prod'}; assert(isequal(seeAlso(fcn),sfcn))
t = CUMPROD Cumulative product of elements. For vectors, CUMPROD(X) is a vector containing the cumulative product of the elements of X. For matrices, CUMPROD(X) is a matrix the same size as X containing the cumulative products over each column. For N-D arrays, CUMPROD(X) operates along the first non-singleton dimension. CUMPROD(X,DIM) works along the dimension DIM. Example: If X = [0 1 2 3 4 5] then cumprod(X,1) is [0 1 2 and cumprod(X,2) is [0 0 0 0 4 10] 3 12 60] See also CUMSUM, SUM, PROD. Overloaded methods: codistributed/cumprod gpuArray/cumprod Reference page in Help browser doc cumprod q = 586 r = CUMSUM, SUM, PROD. Overloaded methods: codistributed/cumprod gpuArray/cumprod Reference page in Help browser doc cumprod r = CUMSUM, SUM, PROD sfcn = 'cumsum' 'sum' 'prod'
12   Pass
%% fcn = 'hankel'; sfcn = {'toeplitz'}; assert(isequal(seeAlso(fcn),sfcn))
t = HANKEL Hankel matrix. HANKEL(C) is a square Hankel matrix whose first column is C and whose elements are zero below the first anti-diagonal. HANKEL(C,R) is a Hankel matrix whose first column is C and whose last row is R. Hankel matrices are symmetric, constant across the anti-diagonals, and have elements H(i,j) = P(i+j-1) where P = [C R(2:END)] completely determines the Hankel matrix. Class support for inputs C,R: double, single, int8, int16, int32, int64, uint8, uint16, uint32, uint64 See also TOEPLITZ. Reference page in Help browser doc hankel q = 544 r = TOEPLITZ. Reference page in Help browser doc hankel r = TOEPLITZ sfcn = 'toeplitz'
13   Pass
%% fcn = 'uisetcolor'; sfcn = {'inspect','propedit','uisetfont'}; assert(isequal(seeAlso(fcn),sfcn))
t = UISETCOLOR Color selection dialog box. C = UISETCOLOR displays a color selection dialog appropriate to the platform, and returns the color selected by the user. The dialog is initialized to white. C = UISETCOLOR([R G B]) displays a dialog initialized to the specified color, and returns the color selected by the user. R, G, and B must be values between 0 and 1. C = UISETCOLOR(H) displays a dialog initialized to the color of the object specified by handle H, returns the color selected by the user, and applies it to the object. H must be the handle to an object containing a color property. C = UISETCOLOR(...,'dialogTitle') displays a dialog with the specified title. If the user presses Cancel from the dialog box, or if any error occurs, the output value is set to the input RGB triple, if provided; otherwise, it is set to 0. Example: hText = text(.5,.5,'Hello World'); C = uisetcolor(hText, 'Set Text Color') See also INSPECT, PROPEDIT, UISETFONT. Reference page in Help browser doc uisetcolor q = 1021 r = INSPECT, PROPEDIT, UISETFONT. Reference page in Help browser doc uisetcolor r = INSPECT, PROPEDIT, UISETFONT sfcn = 'inspect' 'propedit' 'uisetfont'
14   Pass
%% fcn = 'matlab'; sfcn = {}; assert(isequal(seeAlso(fcn),sfcn))
t = '' q = []
15   Pass
%% fcn = 'crazy'; sfcn = {}; assert(isequal(seeAlso(fcn),sfcn))
t = '' q = []