在matlab中运行下列.m文件后出错,请高手指导一下,谢谢

factorial.m
function fact=factorial(u)
%
% factorial function used to demonstrate the use of
% function m-file in MATLAB
%
fact = 1;
if u>0
for i=1:u
fact=fact*i;
end
end

运行后出错提示“??? Error: File: E:\MATLAB7\work\mydemo.m Line: 2 Column: 1
Function definitions are not permitted at the prompt or in scripts.”

那啥, 你不会是把factorial.m写在第一行了吧。。
温馨提示:答案为网友推荐,仅供参考
相似回答