how can i convert 1xn to mxn matrix ?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello i have a variable x[k] k=1,...100
that takes some random numbers as an input, so i have a 1x101 matrix.
How can i create a matrix 20x101 .I tried the repmat function that works but
all of the rows are the same number because this function copies everything
for the first row . How can i actually create 20x101 matrix and still have random numbers
to each row?
Thank you in advance.
0 Kommentare
Antworten (2)
David Hill
am 20 Okt. 2019
Look at rand or randi functions. Depending on what range you want your randon numbers to be in, either function could be used.
x = randi(100,20,101);
Will give you a 20x101 matrix of randon numbers between 1 and 100.
0 Kommentare
Walter Roberson
am 20 Okt. 2019
Use persistent variables in your function. The first 19 times the function is called, just store the 100 values passed in. The 20th time the function is called, store the 100 values and then process the 20 x 100 values to create your 20 x 101 matrix of output and return that.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical 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!