How to validate a text in MatLab? - validatestring -- MatLab
How to validate a text in MatLab? - validatestring -- MatLab How to validate a text in MatLab? [Ans] validatestring [description] validatestring(s,validateS); It will check validity of s against validateS. validateS is valid when only one of validateS is started with s (the matched string is the only one) , or all of validateS are started with S and any of validateS is the substring of others (the matched string is the shortest length one). When validateS is valid, validatestring function will throw the matched string. Otherwise, it will throw exception. more details on: Check validity of text - MATLAB validatestring (mathworks.com) code clear clc a = findArea( 'Rect' ,10,3, 'cm' ) fprintf( "1\n" ); a = findArea( 'octagon' ,7,13, 'in' ) fprintf( "2\n" ); a = findArea( 'TRI' ,10,3, 'mi' ) fprintf( "3\n" ); function a = findArea(shape,h,w,units) expectedShapes = { 'square' , 'rectangle' , ...