Finding the first element of a 1-D array that yields a negative result.

I then want to assign this element of the array to a different variable.

Respuestas (1)

x = normrnd(0,1,[1,20]); % generate 20 random numbers
y = x(find(x<0,1)); % assign the first negative random value to y

La pregunta está cerrada.

Productos

Etiquetas

Preguntada:

A D
el 18 de En. de 2018

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by