how to reduce execution time in my code?

my code takes long time for execution and I tried 'profile' if ~exist('VarName') it takes 60,93sec tempName = strsplit(tmpRow); it takes 28,59sec how can I change these statements. so, that I can reduce the execution time?

2 个评论

Will you post the whole code?
@Sindh: It is impossible to suggest an improvement of your code, if you do not show it. There is no magic strsplit_but_faster command, so the only solution is to reduce the work. But without seeing the code, it is impossible to guess, how to help you.

请先登录,再进行评论。

 采纳的回答

~exist('VarName')
This is a very bad idea. Remember, that exist(s) searches the whole Matlab path for M files, other files, directories and Java classes with this name. In addition it checks for variables in the workspace also. Of course this wastes a lot of time.
Without seeing the context of this command, the purpose of this command is not clear. Guessing the intention is a rather bad idea. But if "VarName" is meant to be a name of a variable, use:
~exist('VarName', 'var')
But even then this might be a bad programming practice. If you post the relevant part of the code, better suggestions are possible.

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by