I have a variable vector like the active: [2 3 4] vector. I select a random element (B) from the active set and use it in a different vector. What function can I use to delete the randomly selected (B) value from the active vector?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
nurhayat sahinkaya
el 25 de Jul. de 2018
Respondida: Stephen23
el 25 de Jul. de 2018
I have a variable vector like the active: [2 3 4] vector. I select a random element (B) from the active set and use it in a different vector. What function can I use to delete the randomly selected (B) value from the active vector?
0 comentarios
Respuesta aceptada
Más respuestas (1)
Dimitris Kalogiros
el 25 de Jul. de 2018
Suppose you have a vector x and you want to select , use and then delete a random element of it.
Have a look at the following :
close all; clc;
% create a vector x
x=10:10:100;
disp(['initial value of x = ' num2str(x)]);
% choose a random element of x
random_index=randi(length(x));
% take your element
y=x(random_index);
disp(['chosen value y = ' num2str(y)]);
% remove this specific element from vector x
x(random_index)=[];
disp(['final value of x = ' num2str(x)]);
0 comentarios
Ver también
Categorías
Más información sobre Install Products en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!