create a vector w1 having the same length as another vector w but containing certain x values
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alberto Acri
am 10 Feb. 2023
Beantwortet: Dyuman Joshi
am 10 Feb. 2023
Hello! I want to create a vector w1 having the same length as another vector w but containing certain x values. How can I fix the code?
v = [100; 177; 186; 124; 175; 211; 132; 144; 124; 111; 133; 152];
w = [25; 14; 33; 20; 14; 22; 29];
number_w = height(w);
x = randsample(v,1);
% w1 = ?
2 Kommentare
Dyuman Joshi
am 10 Feb. 2023
So we have the values for x, but at which indices do you want to put them in w?
Akzeptierte Antwort
Dyuman Joshi
am 10 Feb. 2023
v = [100; 177; 186; 124; 175; 211; 132; 144; 124; 111; 133; 152];
w = [25; 14; 33; 20; 14; 22; 29];
w1=randsample(v,numel(w))
0 Kommentare
Weitere Antworten (0)
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!