Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

2 次查看(过去 30 天)
I then want to assign this element of the array to a different variable.

回答(1 个)

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

此问题已关闭。

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by