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 Kommentare

madhan ravi
madhan ravi am 29 Aug. 2018
Will you post the whole code?
Jan
Jan am 29 Aug. 2018
@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.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jan
Jan am 29 Aug. 2018

1 Stimme

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

Emma
Emma am 29 Aug. 2018
when compared to previous execution it has reduced thank u

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Gefragt:

am 29 Aug. 2018

Kommentiert:

am 29 Aug. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by