搜档网
当前位置:搜档网 › matlab bsxfun hypot用法和原理

matlab bsxfun hypot用法和原理

matlab bsxfun hypot用法和原理
matlab bsxfun hypot用法和原理

C =

0 0 0 0 0 0 0

0.7071 1.4142 2.1213 2.8284 3.5355 4.2426 4.9497

0.8660 1.7321 2.5981 3.4641 4.3301 5.1962 6.0622

1.0000

2.0000

3.0000

4.0000

5.0000

6.0000

7.0000

0.8660 1.7321 2.5981 3.4641 4.3301 5.1962 6.0622

0.7071 1.4142 2.1213 2.8284 3.5355 4.2426 4.9497

0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000

Singleton expansion allows bsxfun to expand the input vectors into a full matrix.

%fun是一个内置函数,可以自己编写,如上例中fun=A.*sin(B)。用bsxfun的时候,将fun子函数调用

C = HYPOT(A,B) returns SQRT(ABS(A).^2+ABS(B).^2) carefully computed to % avoid underflow and overflow.

C=bsxfun(@hypot,A,B) 先将A,B扩充为同维矩阵,再将A、B中每个元素取绝对值的平方后相加,再对这一结果矩阵中的每个元素开平方根。

相关主题