文件名称:optionchoose
介绍说明--下载内容均来自于网络,请自行研究使用
在开发子函数时,matlab存在正则方法和非正则方法,正则方法非常适合一个子函数功能的不断扩展与完善,此函数为辅助函数,增加子函数的可读性
例如一个函数drawfun(x,y,z,5,6),5表示用第5种方法插值,6表示markersize为6,它显然没有drawfun(x,y,z, kriging , markersize ,6)好看懂与理解。 kriging 如何就是5可以用optionchoose(varargin{4},{ linear , spline , inverse , regression , kriging })判断。
再如一个结构体中有很多人的名字和各门课的成绩,想查看张三的所有分数就可以:
student(optionchoose( 张三 ,{student.name}))
如果没有张三这个人,optionchoose会出错退出,用optionchoose( 张三 ,{student.name},1)则返回-1,optionchoose( 张三 ,{student.name},1)在返回-1的同时显示可有的一些选项。
optionchoose( John ,{student.name},1, -case )会强制区分大小写,与john将不是同一个人- check the input option , output the value of option style
Usage:
och=optionchoose(oi,ostyle,|[restrain_error],|[ -case ])
when design functions, string option is apt to read and operate
oi is one option of character, you can write in short only when this
option distinguish other options
ostyle means all possible options, it can be strings or string cell
restrain_error =0 by default setting. if equal other, mean program will
not interrupt, but return-1. restrain>=2, return possible option
(when no match option), when 2, display option mesg.
Notice: uppercase and lowercase of oi(ostyle) seemed same, not
to distinguish, only when -case , then distinguish UPPERCASE
and lowercase of characters
och is numeric opposite to ostyle order, if not in ostyle, return-1
For example:
i=optionchoose( pos ,{ position , potential , pocket }) i=1
See also STRCMP, STRNCMP, STRMATCH
例如一个函数drawfun(x,y,z,5,6),5表示用第5种方法插值,6表示markersize为6,它显然没有drawfun(x,y,z, kriging , markersize ,6)好看懂与理解。 kriging 如何就是5可以用optionchoose(varargin{4},{ linear , spline , inverse , regression , kriging })判断。
再如一个结构体中有很多人的名字和各门课的成绩,想查看张三的所有分数就可以:
student(optionchoose( 张三 ,{student.name}))
如果没有张三这个人,optionchoose会出错退出,用optionchoose( 张三 ,{student.name},1)则返回-1,optionchoose( 张三 ,{student.name},1)在返回-1的同时显示可有的一些选项。
optionchoose( John ,{student.name},1, -case )会强制区分大小写,与john将不是同一个人- check the input option , output the value of option style
Usage:
och=optionchoose(oi,ostyle,|[restrain_error],|[ -case ])
when design functions, string option is apt to read and operate
oi is one option of character, you can write in short only when this
option distinguish other options
ostyle means all possible options, it can be strings or string cell
restrain_error =0 by default setting. if equal other, mean program will
not interrupt, but return-1. restrain>=2, return possible option
(when no match option), when 2, display option mesg.
Notice: uppercase and lowercase of oi(ostyle) seemed same, not
to distinguish, only when -case , then distinguish UPPERCASE
and lowercase of characters
och is numeric opposite to ostyle order, if not in ostyle, return-1
For example:
i=optionchoose( pos ,{ position , potential , pocket }) i=1
See also STRCMP, STRNCMP, STRMATCH
(系统自动生成,下载前可以参看下载内容)
下载文件列表
optionchoose.m