0

我想扫描矩阵的所有行。取所有第一列或 x 列并将它们放入另一个新矩阵中。我怎样才能做到这一点 ?

下面的示例矩阵

    input_matrix_training={
{0.645569620253164,0.443037974683544,0.177215189873418,0.0253164556962025};
{0.620253164556962,0.379746835443038,0.177215189873418,0.0253164556962025};
{0.594936708860759,0.405063291139241,0.164556962025316,0.0253164556962025};
}

例如,让我们扫描行并制作只有第一列的新矩阵

结果 :0.645569620253164, 0.620253164556962, 0.594936708860759

谢谢你

matlab,矩阵

4

2 回答 2

2

首先,你拥有的是一个细胞,这使它变得更加困难。如果可以,请输入如下数据:

input_matrix_training=[
  0.645569620253164 0.443037974683544 0.177215189873418 0.0253164556962025
  0.620253164556962 0.379746835443038 0.177215189873418 0.0253164556962025
  0.594936708860759 0.405063291139241 0.164556962025316 0.0253164556962025];

一旦你有了它,这很容易。

input_matrix_training(:,1)

或第一行:

input_matrix_training(1,:)
于 2012-11-27T23:48:27.643 回答
1

使用冒号运算符。在下面的示例中,(:,1)表示所有行,第 1 列

取第一列:

first_column = input_matrix_training(:,1);

取第 2 到 4 列:

two_to_four = input_matrix_training(:,2:4);

取前 x 列:

x = 3;
first_x = input_matrix_training(:,1:x);
于 2012-11-27T23:52:58.343 回答