iamgui 发表于 2007-1-17 10:36

请问:f(u) 和 MATLAB Function的区别?

我在仿真中想加入一个取余的函数,用user-defined functions模块中的 Fun,在expression中加入mod(u, 2*pi)后,运行出错,错误显示为语法错误;后改用MATLAB Function,在 其中填入mod(u, 2*pi)即不再出错,很想知道这两个的区别,望指教,谢谢!

cdwxg 发表于 2007-1-19 12:08

建议:此类问题多看help
matlab function:The MATLAB Fcn block applies the specified MATLAB function or expression to the input. The output of the function must match the output dimensions of the block or an error occurs.
fun:
The Fcn block applies the specified C language style expression to its input. The expression can be made up of one or more of these components: u -- The input to the block. If u is a vector, u(i) represents the ith element of the vector; u(1) or u alone represents the first element. Numeric constants Arithmetic operators (+ - * /^) Relational operators (== != > < >= <=) -- The expression returns 1 if the relation is true; otherwise, it returns 0. Logical operators (&& || !) -- The expression returns 1 if the relation is true; otherwise, it returns 0. Parentheses Mathematical functions -- abs, acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, hypot, ln, log, log10, pow, power, rem, sgn, sin, sinh, sqrt, tan, and tanh. Workspace variables -- Variable names that are not recognized in the preceding list of items are passed to MATLAB for evaluation. Matrix or vector elements must be specifically referenced (e.g., A(1,1) instead of A for the first element in the matrix).
fun也就是用自定义的函数或者说是表达市进行计算
而matlab function是用matlab现有的函数进行计算。而你用的mod是没有在fun允许的符号范围内的。

iamgui 发表于 2007-1-19 18:00

明白了,多谢指教!
页: [1]
查看完整版本: 请问:f(u) 和 MATLAB Function的区别?