在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/11/28 20:10:43
在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
x=O@ǿʳ4QE\LJ 7Gxk7 |`Q4񻐶/Is~9ȺgVvWkxw؇LNFotNZE0LtVf\&.Yqqe*UD5<0NLa#Y̭Id :X%qb7/4U~ׯwV3|]%"ݕҎZ'DTaY? eB>&F0f ٯ.L)Ra,BT(X"SlM8,Agx`V86)7jȪ8}|\{W^91 ]ǮtznIVl:

在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写在第一行了吧.