random entry selection from a matrix

1 次查看(过去 30 天)
Peter D
Peter D 2012-7-23
how can I select any element randomly from a 1 x n matrix?

回答(1 个)

Doug Hull
Doug Hull 2012-7-23
v = [1:10]
vi = randi(numel(v));
choice = v(vi)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by