How can I decrease the running time of this code?

답변 (1개)

Star Strider
Star Strider 2019년 4월 14일

0 개 추천

Use the diff (link) function:
Ux = diff(X);
Uy = diff(Y);
Uz = diff(Z);
When I timed your code and diff with these matrices:
f = 1000;
X = rand(f, 500);
Y = rand(f, 500);
Z = rand(f, 500);
the results were:
Elapsed time is 0.633127 seconds. % Your Code
Elapsed time is 0.007197 seconds. % ‘diff’
The resulting matrices were the same.
Experiment to get the result you want.

카테고리

도움말 센터 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

질문:

2019년 4월 14일

답변:

2019년 4월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by