Random number selector from double
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have drafted the following code:
num_to_fetch = round(66 / 100 * length(FaY3));
your_subset = FaY3(randperm(length(FaY3), num_to_fetch));
your_subsetFas = (your_subset).*(1.46);
where I chose 66% of the data in the double, multiply it by a constant (1.46), then move it into another double. FaY3 actually comes from a 2x43 double defined as FaXY3. What I want to do is modify this code so that whatever 66% of random numbers are selected from FaXY3(2,:), I need the new matrix to also incorporate FaXY3(1,:).
How would I go about doing this?
0 Kommentare
Antworten (1)
Star Strider
am 24 Jan. 2016
I don’t completely understand what you want with your matrices, but this is one possibility:
D = randi(99, 1 100); % Create Data
I = randperm(100,66); % Indices (66 Unique Values out of 100)
Out = D(I); % Result
I’m not sure what you want to do with your other matrix, but this should get you started.
2 Kommentare
Walter Roberson
am 24 Jan. 2016
Either I do not understand your question or you do not understand Star Strider's answer. If you want corresponding elements of FaY3(1,:) and FaY3(2,:) then use that I index Star Strider shows for both of them.
first_var = FaY3(1,I);
second_var = FaY3(2,I);
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!