在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/09/08 19:24:41
![在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](/uploads/image/z/3164421-21-1.jpg?t=%E5%9C%A8matlab%E4%B8%AD%E8%BF%90%E8%A1%8C%E4%B8%8B%E5%88%97.m%E6%96%87%E4%BB%B6%E5%90%8E%E5%87%BA%E9%94%99%2Cfactorial.mfunction+fact%3Dfactorial%28u%29%25%25+factorial+function+used+to+demonstrate+the+use+of+%25+function+m-file+in+MATLAB%25fact+%3D+1%3Bif+u%3E0for+i%3D1%3Aufact%3Dfact%2Ai%3Bendend%E8%BF%90%E8%A1%8C%E5%90%8E%E5%87%BA%E9%94%99%E6%8F%90%E7%A4%BA%E2%80%9C%3FError%3AFile%3AE%3A%5CMATLAB7%5Cw)
在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写在第一行了吧.