create a vector w1 having the same length as another vector w but containing certain x values

1 次查看(过去 30 天)
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 = ?

采纳的回答

Dyuman Joshi
Dyuman Joshi 2023-2-10
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))
w1 = 7×1
152 124 100 124 111 175 177

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by