Generate a random matrix with 4 specifik values
1 次查看(过去 30 天)
显示 更早的评论
hello i want to generate a random matrix tnat has 16 rows and 10^5 coloums that contains 4 differen values [-1,1,-j,j]. can anyone help me
0 个评论
回答(1 个)
Jeff Miller
2020-11-24
maybe this?
j = 2.5; % insert whatever value of j you want to use
vals = [1,-1, j, -j];
pos = randi(numel(vals),15,10^5);
randmatrix = vals(pos);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!