Path: news.mathworks.com!not-for-mail
From: "Sadik " <sadik.hava@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Calling function during the same script run repeatedly
Date: Fri, 26 Oct 2012 00:17:09 +0000 (UTC)
Organization: University of North Carolina
Lines: 1
Message-ID: <k6ckq5$sg8$1@newscl01ah.mathworks.com>
References: <k6as33$rn7$1@newscl01ah.mathworks.com>
Reply-To: "Sadik " <sadik.hava@gmail.com>
NNTP-Posting-Host: www-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1351210629 29192 172.30.248.48 (26 Oct 2012 00:17:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 26 Oct 2012 00:17:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: news.mathworks.com comp.soft-sys.matlab:781439

You can generate a random number within your script each time you run it. A better one that avoids having the same ID more than once is keeping a variable in your base workspace and never clearing it and incrementing it each time you run your script. This will serve as a process ID. You will also define an additional input to your function to get this ID from the script. Now you know from which script your function is being called. You also had better put this ID into the name of the text files as a prefix so that you will never delete a text file.