Azzera filtri
Azzera filtri

Generate a random matrix with 4 specifik values

6 visualizzazioni (ultimi 30 giorni)
basma awad
basma awad il 24 Nov 2020
Risposto: Jeff Miller il 24 Nov 2020
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

Risposte (1)

Jeff Miller
Jeff Miller il 24 Nov 2020
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);

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by