필터 지우기
필터 지우기

randn

조회 수: 4 (최근 30일)
PChoppala
PChoppala 2011년 11월 11일
Hi
If we declare two rows of random numbers
x = randn(2,100)
and
then use a for loop to move the numbers
for k=1:10
x = 1 0 * x
0 1
end for
This will spread the numbers from (0,0), right? But if I want the numbers to start from (10,10) and if they cross 20, reinitialize them again... is this possible?
If not with randn, can you suggest another solution?
  댓글 수: 1
Jan
Jan 2011년 11월 11일
Please post valid Matlab code to explain your problem. "for k=1:10 x = 1 0 * x 0 1 end for" is not clear.
What does "crossing 20" mathematically mean? The norm, the maximum, the minimum of the two components?

댓글을 달려면 로그인하십시오.

채택된 답변

Daniel Shub
Daniel Shub 2011년 11월 11일
Your question is not really clear ... how about
x = mod(randn(2, 100)+10, 20)
You maybe you mean ...
x = 10*randn(2, 100)+10;
while any(x(:) > 20)
x(x(:) > 20) = 10*randn(sum(x(:) > 20), 1)+10;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by