matlab-字串与数字转换,执行字符串和函数

 数字转字符

 

>> a=111

a =

   111

>> mat2str(a,'class')

ans =

double(111)

>> class(a)

ans =

double
>> num2str(a,'%10.2e')

ans =

1.11e+002

>>

 

 

字符转数字

>> double('abcdef')

ans =

    97    98    99   100   101   102

>>

>> str2num('66.123')

ans =

   66.1230

 

 

 

 

 

执行字符串

 

>> eval('666+99/2')

ans =

  715.5000

 

>> eval('aa=23455')

aa =

       23455

>>

 

执行函数

>> help feval
 FEVAL Execute the specified function.
    FEVAL(F,x1,...,xn) evaluates the function specified by a function
    handle or function name, F, at the given arguments, x1,...,xn.
    For example, if F = @foo, FEVAL(F,9.64) is the same as foo(9.64).
 
    If a function handle is bound to more than one built-in or
    M-file, (that is, it represents a set of overloaded functions),
    then the data type of the arguments x1 through xn, determines
    which function is executed.
 
    FEVAL is usually used inside functions which take function
    handles or function strings as arguments.  Examples include
    FZERO and EZPLOT.
 
    [y1,..,yn] = FEVAL(F,x1,...,xn) returns multiple output arguments.
 
    Within methods that overload built-in functions, use BUILTIN(F,...)
    to execute the original built-in function.  Note that when using
    BUILTIN, F must be a function name and not a function handle.
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值