<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bojan.blog &#187; matlab</title>
	<atom:link href="http://bojand.org/blog/tag/matlab/feed" rel="self" type="application/rss+xml" />
	<link>http://bojand.org/blog</link>
	<description></description>
	<lastBuildDate>Sun, 11 Apr 2010 04:03:46 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Function call counting in Matlab</title>
		<link>http://bojand.org/blog/29.html</link>
		<comments>http://bojand.org/blog/29.html#comments</comments>
		<pubDate>Thu, 23 Mar 2006 13:38:15 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Scientific Computing]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[matlab]]></category>

		<guid isPermaLink="false">http://blog.bojan.info/?p=29</guid>
		<description><![CDATA[Here&#8217;s a neat way to keep track of the cost, i.e. number of function calls in Matlab: rather than using a counter variable and increment it each time a function is called, use the internal Matlab counters, accessible through the FunctionTable struct array. 
The loop below is necessary only to get the index of the [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a neat way to keep track of the cost, i.e. number of function calls in Matlab: rather than using a counter variable and increment it each time a function is called, use the internal Matlab counters, accessible through the <kbd>FunctionTable</kbd> struct array. </p>
<p>The loop below is necessary only to get the index of the desired function in the struct array (If you know a better way of looking up a function in <kbd>FunctionTable</kbd>, let me know!).</p>
<p>Replace the function name <kbd>ftest</kbd> if needed.</p>
<pre class="brush: matlab;">
profile on

% your code comes here
% (cost is counted from &quot;profile on&quot; to &quot;profile off&quot;)

p = profile('info');
for i = 1:size(p.FunctionTable,1)
    if strcmp(p.FunctionTable(i).FunctionName,'ftest')
        break
    end
end
cost = p.FunctionTable(i).NumCalls;
profile off
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bojand.org/blog/29.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
