作业帮 > 综合 > 作业

anss是主程序,其他两个是子程序,都放在一个文件夹里了,而且目录也是那个文件夹

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/06/14 00:43:36
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是主程序,其他两个是子程序,都放在一个文件夹里了,而且目录也是那个文件夹
问题多多啊!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