anss是主程序,其他两个是子程序,都放在一个文件夹里了,而且目录也是那个文件夹为什么就是有错误呢?-----------------------------------------------------------------------anss.m---------------------------------------
为什么就是有错误呢?
-----------------------------------------------------------------------
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
------------------------------------------------------------------------
问题多多啊!
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
关于线代的问题.晕了,速32.非齐次线性方程组AX=b中未知数的个数为n,方程个数为m,系数矩阵A 2020-05-14 …
初三二元一次方程填空(x^2+y^2-5)^2=4,则x^2+y^2=()如果n是方程x^2+mx 2020-05-20 …
持续性能评价中( )是指把n个程序组成的工作负荷中每个程序执行的速率(或执行所费时间的倒数)加起 2020-05-26 …
一般地,由N个程序员组成的程序员小组在完成相同规模的软件时需要的通信数量C(N)=()。 2020-05-31 …
已知下列n(n为正整数)歌关于X的一元二次方程X^2-1=0----1X^2+X-2=0----2 2020-06-02 …
高一那个程序框图有关的东西怎么学啊?…还有那个数列 2020-06-03 …
关于方程的笨笨问题是不是n个方程只能解出n个未知数.或者说n个未知数至少要有n个方程才有唯一的解? 2020-06-26 …
为什么齐次线性方程组的秩r=n,它有唯一零解我是这样理解的,应该错了.秩为n,就是说行变换之后仍然 2020-06-30 …
设方程组Ax=b中未知数的个数为n,方程个数为m,系数矩阵A的秩为r,则().(A)r=m时,方程 2020-07-08 …
证明:含有n个方程组的n元线性方程组AX=B对于任意B有解的充分必要条件是它的系数矩证明:含有n个 2020-07-08 …