在matlab中运行下列.m文件后出错,factorial.mfunction fact=factorial(u)%% factorial function used to demonstrate the use of % function m-file in MATLAB%fact = 1;if u>0for i=1:ufact=fact*i;endend运行后出错提示“?Error:File:E:\MATLAB7\w

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/05 12:24:48
在matlab中运行下列.m文件后出错,factorial.mfunction fact=factorial(u)%% factorial function used to demonstrate the use of % function m-file in MATLAB%fact = 1;if u>0for i=1:ufact=fact*i;endend运行后出错提示“?Error:File:E:\MATLAB7\w

在matlab中运行下列.m文件后出错,factorial.mfunction fact=factorial(u)%% factorial function used to demonstrate the use of % function m-file in MATLAB%fact = 1;if u>0for i=1:ufact=fact*i;endend运行后出错提示“?Error:File:E:\MATLAB7\w
在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.”

在matlab中运行下列.m文件后出错,factorial.mfunction fact=factorial(u)%% factorial function used to demonstrate the use of % function m-file in MATLAB%fact = 1;if u>0for i=1:ufact=fact*i;endend运行后出错提示“?Error:File:E:\MATLAB7\w
那啥, 你不会是把factorial.m写在第一行了吧.