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 Comments

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.

Sign in to comment.

 Accepted Answer

~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.

1 Comment

when compared to previous execution it has reduced thank u

Sign in to comment.

More Answers (0)

Categories

Asked:

on 29 Aug 2018

Commented:

on 29 Aug 2018

Community Treasure Hunt

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

Start Hunting!