关于MATLAB编程的 小问题 ??!!

2025-06-26 17:38:43
推荐回答(2个)
回答1:

ones(9)是一个9*9的全1阵
ones(8,7)是8*7的全1阵
下面是参考
ONES Ones array.
ONES(N) is an N-by-N matrix of ones.

ONES(M,N) or ONES([M,N]) is an M-by-N matrix of ones.

ONES(M,N,P,...) or ONES([M N P ...]) is an M-by-N-by-P-by-... array of
ones.

ONES(SIZE(A)) is the same size as A and all ones.

ONES with no arguments is the scalar 1.

ONES(M,N,...,CLASSNAME) or ONES([M,N,...],CLASSNAME) is an M-by-N-by-...
array of ones of class CLASSNAME.

Note: The size inputs M, N, and P... should be nonnegative integers.
Negative integers are treated as 0.

Example:
x = ones(2,3,'int8');

See also eye, zeros.

Reference page in Help browser
doc ones

回答2:

这下试试看:是个草帽图

x=-8:0.5:8;y=x';
ones(size(y))*x;y=y*ones(size(x));x=ans;
r=sqrt(x.^2+y.^2)+eps;
z=sin(r)./r;
mesh(z)