poster
2019-12-14, 20:46
如何生成n个样本并在另一列中用数字标记。
我有这个:
n= 5; sample1= randn(n,1) sample2= randn(n,1) sample1 = 0.3481 0.2328 0.6735 -0.1274 -0.4146 sample2 = -1.4964 -0.7325 -1.0193 -0.6829 -0.4427 我想要
sample1 = 0.3481 -1 0.2328 -1 0.6735 -1 -0.1274 -1 -0.4146 -1 sample2 = -1.4964 1 -0.7325 1 -1.0193 1 -0.6829 1 -0.4427 1 并在矩阵中包含所有数据:
data= 0.3481 -1 0.2328 -1 0.6735 -1 -0.1274 -1 -0.4146 -1 -1.4964 1 -0.7325 1 -1.0193 1 -0.6829 1 -0.4427 1 How to do this?
回答:
尝试这个:
n=5; sample1=[randn(n,1) -1*ones(n,1)]; sample2=[randn(n,1) ones(n,1)]; data=[sample1; sample2];
更多&回答... (https://stackoverflow.com/questions/5380111)
我有这个:
n= 5; sample1= randn(n,1) sample2= randn(n,1) sample1 = 0.3481 0.2328 0.6735 -0.1274 -0.4146 sample2 = -1.4964 -0.7325 -1.0193 -0.6829 -0.4427 我想要
sample1 = 0.3481 -1 0.2328 -1 0.6735 -1 -0.1274 -1 -0.4146 -1 sample2 = -1.4964 1 -0.7325 1 -1.0193 1 -0.6829 1 -0.4427 1 并在矩阵中包含所有数据:
data= 0.3481 -1 0.2328 -1 0.6735 -1 -0.1274 -1 -0.4146 -1 -1.4964 1 -0.7325 1 -1.0193 1 -0.6829 1 -0.4427 1 How to do this?
回答:
尝试这个:
n=5; sample1=[randn(n,1) -1*ones(n,1)]; sample2=[randn(n,1) ones(n,1)]; data=[sample1; sample2];
更多&回答... (https://stackoverflow.com/questions/5380111)