Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
 
 
主题工具 显示模式
旧 2008-03-30, 16:49   #1
xiaotie
初级会员
 
注册日期: 2008-03-28
年龄: 46
帖子: 19
声望力: 18
xiaotie 正向着好的方向发展
默认 [求助]function 问题

我编了一个如下
function [y,n]=jacobi(A,b,x0,eps)
回车时系统
??? function [y,n]=jacobi(A,b,x0,eps)
|
Error: Function definitions are not permitted at the prompt or in scripts.
打入
HELP function
回车时系统
Warning: Could not find an exact (case-sensitive) match for 'HELP'.
I:\Program Files\MATLAB71\toolbox\matlab\helptools\help.m is a case-insensitive match and will be used instead.
You can improve the performance of your code by using exact
name matches and we therefore recommend that you update your
usage accordingly. Alternatively, you can disable this warning using
warning('off','MATLAB:dispatcher:InexactMatch').
FUNCTION Add new function.
New functions may be added to MATLAB's vocabulary if they
are expressed in terms of other existing functions. The
commands and functions that comprise the new function must
be put in a file whose name defines the name of the new
function, with a filename extension of '.m'. At the top of
the file must be a line that contains the syntax definition
for the new function. For example, the existence of a file
on disk called STAT.M with:

function [mean,stdev] = stat(x)
%STAT Interesting statistics.
n = length(x);
mean = sum(x) / n;
stdev = sqrt(sum((x - mean).^2)/n);

defines a new function called STAT that calculates the
mean and standard deviation of a vector. The variables
within the body of the function are all local variables.
See SCRIPT for procedures that work globally on the work-
space.

A subfunction that is visible to the other functions in the
same file is created by defining a new function with the FUNCTION
keyword after the body of the preceding function or subfunction.
For example, avg is a subfunction within the file STAT.M:

function [mean,stdev] = stat(x)
%STAT Interesting statistics.
n = length(x);
mean = avg(x,n);
stdev = sqrt(sum((x-avg(x,n)).^2)/n);

%-------------------------
function mean = avg(x,n)
%AVG subfunction
mean = sum(x)/n;

Subfunctions are not visible outside the file where they are defined.
Normally functions return when the end of the function is reached.
A RETURN statement can be used to force an early return.

See also script, return, varargin, varargout, nargin, nargout,
inputname, mfilename.

Reference page in Help browser
doc function
xiaotie 当前离线   回复时引用此帖
 


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码


相似的主题
主题 主题作者 版面 回复 最后发表
matlab 中反函数运算。 zhanggongrui MATLAB论坛 0 2008-04-29 00:03
[求助] INTEL行 AMD为什么不行! isomia MATLAB论坛 5 2008-04-23 12:23
【求助】BP预测程序出错 robberzhou MATLAB论坛 0 2007-06-08 12:44
求救-----基于小波域的数字水印 tcgqb111 MATLAB论坛 0 2007-05-24 07:27


所有时间均为北京时间。现在的时间是 15:37


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.