anss是主程序,其他两个是子程序,都放在一个文件夹里了,而且目录也是那个文件夹为什么就是有错误呢?-----------------------------------------------------------------------anss.m---------------------------------------
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/27 12:24:04
![anss是主程序,其他两个是子程序,都放在一个文件夹里了,而且目录也是那个文件夹为什么就是有错误呢?-----------------------------------------------------------------------anss.m---------------------------------------](/uploads/image/z/6114907-19-7.jpg?t=anss%E6%98%AF%E4%B8%BB%E7%A8%8B%E5%BA%8F%2C%E5%85%B6%E4%BB%96%E4%B8%A4%E4%B8%AA%E6%98%AF%E5%AD%90%E7%A8%8B%E5%BA%8F%2C%E9%83%BD%E6%94%BE%E5%9C%A8%E4%B8%80%E4%B8%AA%E6%96%87%E4%BB%B6%E5%A4%B9%E9%87%8C%E4%BA%86%2C%E8%80%8C%E4%B8%94%E7%9B%AE%E5%BD%95%E4%B9%9F%E6%98%AF%E9%82%A3%E4%B8%AA%E6%96%87%E4%BB%B6%E5%A4%B9%E4%B8%BA%E4%BB%80%E4%B9%88%E5%B0%B1%E6%98%AF%E6%9C%89%E9%94%99%E8%AF%AF%E5%91%A2%3F-----------------------------------------------------------------------anss.m---------------------------------------)
anss是主程序,其他两个是子程序,都放在一个文件夹里了,而且目录也是那个文件夹为什么就是有错误呢?-----------------------------------------------------------------------anss.m---------------------------------------
anss是主程序,其他两个是子程序,都放在一个文件夹里了,而且目录也是那个文件夹
为什么就是有错误呢?
-----------------------------------------------------------------------
anss.m
---------------------------------------------------------------------------
biglength =100;
bigwidth = 50;
siz = 1;
a1=5;
a2=0;
% b b
% a b c
% a b a b
amount1 = circleone(a1);
amount2 = circletwo(a1,biglength,bigwidth);
amount3 = circletwo(a1,bigwidth,biglength);
amount =max([amount1 amount2 amount3])
------------------------------------------------------------------------
circleone.m
---------------------------------------------------------------------
function circleone(r)
x=fix(biglength/2/r);
y=fix(bigwidth/2/r);
sonamount = x*y;
if (biglength-x*2*r)>0.73*r
sonamount=sonamount+y-1;
end
if ((bigwidth-y*2*r)>(0.73*r))
sonamount=sonamount+x-1;
end
if (((biglength-x*2*r)>0.73*r)&((bigwidth-y*2*r)>r))||(((bigwidth-y*2*r)>0.73*r)&((biglength-x*2*r)>r))
sonamount=sonamount+1;
end
circle=sonamount;
end
-----------------------------------------------------------------------
function circletwo(r,a,b)
% 之前(r,x,y)或者(r,y,x)来更改顺序
x=fix(a/2/r);
if ((a/2/r-x)>r)
y=fix((b-2*r)/1.73/r)+1;
sonamount=x*y;
else
y=fix((b-2*r)/1.73/r)+1;
if (y/2 -fix(y/2))0
sonamount=(y-1)*(2*x-1)/2+x;
else
sonamount=(2*x-1)*y/2;
end
end
circletwo=sonamount;
end
------------------------------------------------------------------------
anss是主程序,其他两个是子程序,都放在一个文件夹里了,而且目录也是那个文件夹为什么就是有错误呢?-----------------------------------------------------------------------anss.m---------------------------------------
问题多多啊!
circleone中biglength和bigwidth都没赋初值.
而且matlab的函数不是这样返回结果的.
函数的定义是这样的:
function [y1,...,yN] = myfun(x1,...,x)
Matlab中帮助中的例子
function y = average(x)if ~isvector(x)
error('Input must be a vector')
end
y = sum(x)/length(x);
end