M.一种in Content

-

Subtraction

描述

例子

C=一种-B.减去阵列B.来自阵列一种通过减去相应的元素。尺寸一种一种ndB.必须是相同的或兼容的

如果大小一种一种ndB.兼容,那么两个数组隐含地扩展以互相匹配。例如,如果一种orB.is a scalar, then the scalar is combined with each element of the other array. Also, vectors with different orientations (one row vector and one column vector) implicitly expand to form a matrix.

c =减去(一种B.的)是执行的替代方法A - B.,但很少使用。它使运算符可用于类。

例子

全部收缩

创建一个数组,一种,并从中减去标量值。

a = [2 1;3 5];c = a  -  2
C=2×20 -1 1 3

The scalar is subtracted from each entry of一种

Create two arrays,一种一种ndB.,并减去第二个,B.,从第一个,一种

a = [1 0;2 4];B = [5 9;2 1];c = a  -  b
C=2×2-4 -9 0 3

元素B.从相应的元素中减去一种

使用语法-Cto negate the elements ofC

-C
ANS =.2×24 9 0 -3

Create a 1-by-2 row vector and 3-by-1 column vector and subtract them.

a = 1:2;B =(1:3)';A  -  B.
ANS =.3.×20 1 -1 0 -2 -1

The result is a 3-by-2 matrix, where each (i,j) element in the matrix is equal to a(j) - b(i)

一种 = [ 一种 1 一种 2 ] B. = [ B. 1 B. 2 B. 3. ] 一种 - B. = [ 一种 1 - B. 1 一种 2 - B. 1 一种 1 - B. 2 一种 2 - B. 2 一种 1 - B. 3. 一种 2 - B. 3. ]

创建一个矩阵,一种。Scale the elements in each column by subtracting the mean.

A =[19 3; 2 7 8]
A =2×3.1 9 3 2 7 8
一种-mean(A)
ANS =.2×3.-0.5000 1.0000 -2.5000 0.5000 -1.0000 2.5000

输入参数

全部收缩

操作数,指定为标量,向量,矩阵或多维数组。输入一种一种ndB.必须具有相同的大小或具有兼容的大小(例如,一种是一个M.-B.y-N.矩阵和B.是一个标量或1-B.y-N.行矢量)。有关更多信息,请参阅兼容数组尺寸,用于基本操作

  • 操作数with an integer data type cannot be complex.

  • 如果一个输入是一个datetime大批,期间阵列,或者日历阵列,另一个输入中的数字值被视为24小时的数量。

数据类型:单身的|双倍的|INT8.|int16|int32|INT64.|uint8.|uint16|UINT32|UINT64|逻辑|char|datetime|期间|日历
复数支持:金宝app是的

Compatibility Considerations

展开全部

R2016B的行为更改

B.ehavior changed in R2020b

扩展能力

Introduced before R2006a