how can i determine the time it took to run an input?

1 回表示 (過去 30 日間)
Morena Patrick Malashe
Morena Patrick Malashe 2019 年 4 月 10 日
回答済み: Jan 2019 年 4 月 10 日
n = length(V);
S = zeros(n,2*n);
for i = 1:n
for j = 2:i
for k = 1:n
S(i,j+k) = V(i);
end
end
end
First determine the number of instructions as a function of n, thus find T(n) for a single execution
of this algorithm?
  2 件のコメント
madhan ravi
madhan ravi 2019 年 4 月 10 日
have you seen tic toc ? if you want to know the running time of a script.
Jan
Jan 2019 年 4 月 10 日
編集済み: Jan 2019 年 4 月 10 日
@Morena: I've formatted your code to make it easier to read. You can do this by your own also.
"determine the number of instructions as a function of n"
This is not trivial. What exactly is "an instruction"?

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2019 年 4 月 10 日
You can use tic and toc, or more accurately timeit.

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

製品


リリース

R11.1

Community Treasure Hunt

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

Start Hunting!

Translated by