Creating a random matrix with specific values?

6 ビュー (過去 30 日間)
Anum Ahmed
Anum Ahmed 2020 年 2 月 20 日
回答済み: Guillaume 2020 年 2 月 20 日
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

採用された回答

Guillaume
Guillaume 2020 年 2 月 20 日
valueset = [0, 90, 180];
desiredsize = [1, 100];
desiredmatrix = valueset(randi(numel(valueset), desiredsize))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by