Creating a random matrix with specific values?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Anum Ahmed
am 20 Feb. 2020
Beantwortet: Guillaume
am 20 Feb. 2020
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 Kommentare
Akzeptierte Antwort
Guillaume
am 20 Feb. 2020
valueset = [0, 90, 180];
desiredsize = [1, 100];
desiredmatrix = valueset(randi(numel(valueset), desiredsize))
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!