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.”