<?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>MATLAB pour les geeks &#187; evalc</title>
	<atom:link href="https://blog.developpez.com/matlab4geek/?feed=rss2&#038;tag=evalc" rel="self" type="application/rss+xml" />
	<link>https://blog.developpez.com/matlab4geek</link>
	<description>&#62;&#62;why(393) </description>
	<lastBuildDate>Fri, 09 Jan 2015 13:05:12 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>evalc</title>
		<link>https://blog.developpez.com/matlab4geek/?p=759</link>
		<comments>https://blog.developpez.com/matlab4geek/?p=759#comments</comments>
		<pubDate>Fri, 15 Feb 2013 15:33:55 +0000</pubDate>
		<dc:creator><![CDATA[tug83]]></dc:creator>
				<category><![CDATA[Best-of des commandes MATLAB utiles]]></category>
		<category><![CDATA[evalc]]></category>
		<category><![CDATA[MATLAB Compiler]]></category>
		<category><![CDATA[pragma]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/matlab4geek/?p=759</guid>
		<description><![CDATA[On a vu dans l&#8217;article précédent qu&#8217;evalc est utile pour enlever le verbose : disp, fprintf &#8230; Maintenant si on veut compiler son code qui utilise evalc avec le MATLAB Compiler , il est nécéssaire de rajouter le pragma %#function Comme expliqué dans la doc %#function The %#function pragma informs MATLAB Compiler that the specified [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>On a vu dans l&rsquo;article précédent qu&rsquo;evalc est utile pour enlever le verbose : disp, fprintf &#8230;<br />
Maintenant si on veut compiler son code qui utilise evalc avec le MATLAB Compiler , il est nécéssaire de rajouter le pragma <strong>%#function</strong> <span id="more-759"></span></p>
<p>Comme expliqué dans la doc  <a href="http://www.mathworks.fr/fr/help/compiler/function.html" target="_blank">%#function</a></p>
<blockquote><p>The %#function pragma informs MATLAB Compiler that the specified function(s) will be called through an feval, eval, or Handle Graphics callback.</p></blockquote>
<p>Ok <strong>evalc n&rsquo;est pas cité mais pourtant il faut le faire</strong>!</p>
<p>Si on veut compiler ma fonction bidon matlab4geek (du billet précédent) par exemple , on pourrait ecrire une fonction parent :</p>
<div class="codecolorer-container matlab default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="matlab codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000FF;">function</span> <span style="color: #080;">&#91;</span>blablabla,y<span style="color: #080;">&#93;</span> &nbsp;=test<br />
<br />
<span style="color: #080;">&#91;</span>blablabla,y<span style="color: #080;">&#93;</span> = <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/evalc.html"><span style="color: #0000FF;">evalc</span></a><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'matlab4geek(2)'</span><span style="color: #080;">&#41;</span>;</div></div>
<p>puis la compiler</p>
<div class="codecolorer-container matlab default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="matlab codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mcc -mv test</div></div>
<p>en essayant de l&rsquo;executer:</p>
<div class="codecolorer-container matlab default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="matlab codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">!test</div></div>
<p>on va avoir le message d&rsquo;erreur :</p>
<blockquote><p>Error using evalc<br />
Undefined function &lsquo;matlab4geek&rsquo; for input arguments of type &lsquo;double&rsquo;. </p>
<p>Error in test (line 3) </p></blockquote>
<p>Donc en effet le MATLAB Compiler n&rsquo;a pas compris lors de la compilation que la chaine de caractère matlab4geek était une fonction à embarquer.</p>
<p>La solution est donc :<br />
<!--more--></p>
<p>de rajouter sous le nom de la fonction <strong>%#function matlab4geek</strong></p>
<div class="codecolorer-container matlab default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="matlab codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000FF;">function</span> <span style="color: #080;">&#91;</span>blablabla,y<span style="color: #080;">&#93;</span> &nbsp;=test<br />
<span style="color: #228B22;">%#function matlab4geek</span><br />
<span style="color: #080;">&#91;</span>blablabla,y<span style="color: #080;">&#93;</span> = <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/evalc.html"><span style="color: #0000FF;">evalc</span></a><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'matlab4geek(2)'</span><span style="color: #080;">&#41;</span>;</div></div>
<p>Sur ce bon week-end à tous les Matlab geek!</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chut!</title>
		<link>https://blog.developpez.com/matlab4geek/?p=748</link>
		<comments>https://blog.developpez.com/matlab4geek/?p=748#comments</comments>
		<pubDate>Thu, 07 Feb 2013 08:57:08 +0000</pubDate>
		<dc:creator><![CDATA[tug83]]></dc:creator>
				<category><![CDATA[Best-of des commandes MATLAB utiles]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[echo off]]></category>
		<category><![CDATA[evalc]]></category>
		<category><![CDATA[fprintf]]></category>
		<category><![CDATA[mute]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/matlab4geek/?p=748</guid>
		<description><![CDATA[ou comment faire taire MATLAB ?! J&#8217;avais écris un logiciel avec pleins de fprintf afin de pouvoir créer un log avec diary. Evidemment ça ralentit le process le fait de faire afficher pleins de lignes dans le Command Window. Là l&#8217;idée c&#8217;était de pouvoir ajouter une option qui fasse que les fprintf n&#8217;affichent rien. J&#8217;aurais [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>ou comment faire taire MATLAB ?!<br />
J&rsquo;avais écris un logiciel avec <strong>pleins de fprintf </strong> afin de pouvoir créer un log avec diary.<br />
Evidemment ça ralentit le process le fait de faire afficher pleins de lignes dans le Command Window.<br />
Là l&rsquo;idée c&rsquo;était de pouvoir ajouter une option qui fasse que les fprintf n&rsquo;affichent rien.<br />
J&rsquo;aurais pu rajouter une checkbox dans l&rsquo;interface que j&rsquo;aurais appelée &laquo;&nbsp;verbosity&nbsp;&raquo; . Si cette checkbow n&rsquo;était pas cochée , cela signifait que l&rsquo;opérateur ne voulait rien voir à l&rsquo;écran.<br />
Mais bon vu que j&rsquo;en avais plus de 3000 lignes de fprintf je n&rsquo;avais pas envie de faire 300 if-test du style:</p>
<div class="codecolorer-container matlab default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="matlab codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000FF;">if</span> verbosity <span style="color: #228B22;">% checkbox has value 1</span><br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fprintf.html"><span style="color: #0000FF;">fprintf</span></a><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'\n ...'</span><span style="color: #080;">&#41;</span><br />
<span style="color: #0000FF;">end</span></div></div>
<p>La solution est en fait toute simple et ne requière aucune modification de code &#8230; (solution page suivante ) <span id="more-748"></span></p>
<p>il suffit d&rsquo;utilser <strong>evalc</strong></p>
<p>Prenons un exemple simple où il n&rsquo;ya que 2 fprintf (et pas 3000 comme dans mon cas)</p>
<div class="codecolorer-container matlab default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="matlab codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000FF;">function</span> &nbsp;y = matlab4geek<span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span><br />
<span style="color: #228B22;">% dummy code to multiply by 3 an input</span><br />
<span style="color: #228B22;">%</span><br />
<span style="color: #228B22;">% Input : numerical value</span><br />
<span style="color: #228B22;">% Output : input multiplied by 3</span><br />
<span style="color: #228B22;">%</span><br />
<span style="color: #228B22;">% Example : y = matlabgeek(2) will return 6</span><br />
<span style="color: #228B22;">%</span><br />
<span style="color: #228B22;">% See also why(393)</span><br />
<span style="color: #228B22;">%</span><br />
<span style="color: #228B22;">% Create Date : 07-Feb-2013</span><br />
<span style="color: #228B22;">% Author : Aurelien QUEFFURUST</span><br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fprintf.html"><span style="color: #0000FF;">fprintf</span></a><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'\n %s'</span>,<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/datestr.html"><span style="color: #0000FF;">datestr</span></a><span style="color: #080;">&#40;</span><a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/now.html"><span style="color: #0000FF;">now</span></a><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fprintf.html"><span style="color: #0000FF;">fprintf</span></a><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'\n input x :%d\n'</span>,x<span style="color: #080;">&#41;</span><br />
y = x*<span style="color: #33f;">3</span>;</div></div>
<p>Si je l&rsquo;execute il va m&rsquo;afficher :</p>
<blockquote><p>&gt;&gt;y = matlab4geek(2)</p>
<p> 07-Feb-2013 09:51:01<br />
 input x :2</p>
<p>y =</p>
<p>     6</p></blockquote>
<p>Mais pour le faire taire il suffit de faire:</p>
<blockquote><p>[blablabla,y] = evalc(&lsquo;matlab4geek(2)&rsquo;);</p></blockquote>
<p>Le ; est très important !</p>
<p>blablabla vous l&rsquo;aurez compris aura capturé les lignes et y la valeur que je souhaite récupérer.</p>
<p>Bref donc le gars qui veut utiliser mon soft sans display il n&rsquo;a qu&rsquo;à l&rsquo;appler via evalc et moi ça m&rsquo;évite 3000 if-else à  implémenter <img src="https://blog.developpez.com/matlab4geek/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
