Explain this line of code (Index)
이전 댓글 표시
Hi, can someone explain to me what these line of code mean?
L = 2400
i = ceil(L*rand(1))
x = periodic_index(i, L, 1);
I understand what the code in the first two lines mean. My main concern is with the code in the last line.
Thanks in advance.
댓글 수: 1
Arif Hoq
2022년 2월 18일
periodic_index is a user defined function i guess
채택된 답변
추가 답변 (1개)
L = 2400 ; % a number
i = ceil(L*rand(1)) % ceil(rand(1)) always gives 1
x = periodic_index(i, L, 1); % From periodic_index array extract 2400x2400x1 element if it is array
댓글 수: 2
Kai Yi Ng
2022년 2월 18일
Yes rand/ rand(1) will give you a random number lying betweem (0,1), as the function ceil is used, result will be 1. You can check it by yourself.
for i = 1:100
ceil(rand)
end
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!