Explain this line of code (Index)
Show older comments
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 Comment
Arif Hoq
on 18 Feb 2022
periodic_index is a user defined function i guess
Accepted Answer
More Answers (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 Comments
Kai Yi Ng
on 18 Feb 2022
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
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!