Time consumed by a function in a code
显示 更早的评论
I have made an equivalent function of variable fractional delay and running it with a for loop and with the other functions like xcorr in the code. I have to find the time taken by the code in executing the equivalent function only and not the xcorr function. I have used tic toc, but it gives the time for the whole code.
回答(1 个)
KSSV
2020-8-17
Read about profiler. You can use tic toc.
t1 = tic ;
val = myfunction(inputs) ;
t1 = toc(t1) ;
4 个评论
Rashi Mehrotra
2020-8-17
KSSV
2020-8-17
N = 10 ;
t1 = zeros(N,1) ;
t2 = zeros(N,1) ;
for i = 1:N
ti = tic ;
val = vfd(input) ; % your function
t1(i) = toc(i) ;
tj = tic ;
val = xcorr(input) ;
t2(i) = toc(tj) ;
end
plot(1:N,t1,'r',1:N,t2,'b')
Also read about profiler.
Rashi Mehrotra
2020-8-17
Rashi Mehrotra
2020-8-17
类别
在 帮助中心 和 File Exchange 中查找有关 Correlation and Convolution 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!