Matlab 多维数组中的2个随机向量

Matlab 多维数组中的2个随机向量,matlab,Matlab,我正在尝试这样做: weights = rand(64,1); % creates an array with 64 initial weights weights(:,2) = rand(40,1); % creates an array with 40 initial weights 正如代码所解释的:用64个随机值填充第一个向量,然后对第二个向量执行相同的操作,并将它们放入同一个变量中。因此,我是abel,可以这样访问它们: weights(:,1) % <-- will disp

我正在尝试这样做:

weights = rand(64,1); % creates an array with 64 initial weights
weights(:,2) = rand(40,1); % creates an array with 40 initial weights
正如代码所解释的:用64个随机值填充第一个向量,然后对第二个向量执行相同的操作,并将它们放入同一个变量中。因此,我是abel,可以这样访问它们:

weights(:,1) % <-- will display entire first vector
weights(:,2) % <-- display entire second vector

weights(:,1)%您不能这样做,因为第一个调用创建了一个具有
size(64,1)
的矩阵。因此,所有列必须有
64行
,而不是
40行

您可以使用单元格,例如

weights{1} = rand(64,1); % creates an array with 64 initial weights
weights{2} = rand(40,1); % creates an array with 40 initial weights
像这样使用它们

weights{1}
weights{2}

但是,此解决方案是否对您有用取决于您希望对数据执行的其他操作。

您无法执行此操作,因为第一次调用将创建一个大小为
的矩阵(64,1)
。因此,所有列必须有
64行
,而不是
40行

您可以使用单元格,例如

weights{1} = rand(64,1); % creates an array with 64 initial weights
weights{2} = rand(40,1); % creates an array with 40 initial weights
像这样使用它们

weights{1}
weights{2}

但是,此解决方案是否对您有用取决于您希望对数据执行的其他操作。

您无法执行此操作,因为第一次调用将创建一个大小为
的矩阵(64,1)
。因此,所有列必须有
64行
,而不是
40行

您可以使用单元格,例如

weights{1} = rand(64,1); % creates an array with 64 initial weights
weights{2} = rand(40,1); % creates an array with 40 initial weights
像这样使用它们

weights{1}
weights{2}

但是,此解决方案是否对您有用取决于您希望对数据执行的其他操作。

您无法执行此操作,因为第一次调用将创建一个大小为
的矩阵(64,1)
。因此,所有列必须有
64行
,而不是
40行

您可以使用单元格,例如

weights{1} = rand(64,1); % creates an array with 64 initial weights
weights{2} = rand(40,1); % creates an array with 40 initial weights
像这样使用它们

weights{1}
weights{2}

但是,此解决方案是否对您有用取决于您对数据的其他用途。

使用Nemesis等细胞的类似解决方案是结构,例如:

weights.a = rand(64,1);
weights.b = rand(40,1);
weights.a, % <-- will display entire first vector
weights.b, % <-- will display entire second vector
weights.a=rand(64,1);
权重b=兰特(40,1);

权重。a,%使用Nemesis等细胞的类似解决方案是结构,例如:

weights.a = rand(64,1);
weights.b = rand(40,1);
weights.a, % <-- will display entire first vector
weights.b, % <-- will display entire second vector
weights.a=rand(64,1);
权重b=兰特(40,1);

权重。a,%使用Nemesis等细胞的类似解决方案是结构,例如:

weights.a = rand(64,1);
weights.b = rand(40,1);
weights.a, % <-- will display entire first vector
weights.b, % <-- will display entire second vector
weights.a=rand(64,1);
权重b=兰特(40,1);

权重。a,%使用Nemesis等细胞的类似解决方案是结构,例如:

weights.a = rand(64,1);
weights.b = rand(40,1);
weights.a, % <-- will display entire first vector
weights.b, % <-- will display entire second vector
weights.a=rand(64,1);
权重b=兰特(40,1);
重量a,%