How to store values from toc into an array
이전 댓글 표시
help with bonus question
답변 (1개)
Walter Roberson
2018년 2월 7일
tic;
for K = 1 : 10
times(K) = toc;
end
댓글 수: 6
Raiven Balderas
2018년 2월 7일
편집: Walter Roberson
2018년 2월 7일
Walter Roberson
2018년 2월 7일
You are overwriting all of timeslow, timeslist, timesieve each iteration of the loop.
for N = 1 : 5
n = 10^N;
...
timeslow(n) = toc;
...
end
Raiven Balderas
2018년 2월 7일
Walter Roberson
2018년 2월 7일
Only initialize timeslow to zero before the for loop, not in the for loop.
Raiven Balderas
2018년 2월 7일
Walter Roberson
2018년 2월 7일
편집: Walter Roberson
2018년 2월 7일
You write a function named prime_count that takes n as an input and returns a vector named Upsilon which is of length n, each element of which is the number of prime numbers less than or equal to its index. The function prime_count must call prime_sieve exactly once -- however, it is not required that your function use the results returned by prime_sieve .
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!