声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3429|回复: 2

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

[复制链接]
发表于 2007-1-17 10:36 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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

使用道具 举报

发表于 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允许的符号范围内的。
 楼主| 发表于 2007-1-19 18:00 | 显示全部楼层
明白了,多谢指教!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-12-26 15:54 , Processed in 0.093737 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表