Creating a random matrix with specific values?
5 次查看(过去 30 天)
显示 更早的评论
Hello,
Can someone guide me how to generate a random matrix in Matlab with only specific values in it.
For example, lets say I need a 1*100 element array with values only 0,90,180 in it. How can I do it using Matlab.
Many Thanks
0 个评论
采纳的回答
Guillaume
2020-2-20
valueset = [0, 90, 180];
desiredsize = [1, 100];
desiredmatrix = valueset(randi(numel(valueset), desiredsize))
0 个评论
更多回答(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!