<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2734678215072839381</id><updated>2024-10-25T01:32:33.536-07:00</updated><title type='text'>DSP</title><subtitle type='html'>This blog is for the people who are interested in learning about signal processing and digital signal processing. This blog not only helps the researcher in understanding the basics of above mentioned signal processing but also develop an understanding in using MATLAB. Matlab is a software that is not only used extensively in all types of engineering but also in other fields. This blog helps in building the knowledge of Matlab commands and how they can implement.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>267</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-1428123965971172484</id><published>2014-10-19T02:00:00.002-07:00</published><updated>2014-10-19T02:00:55.682-07:00</updated><title type='text'>http://monthlyyouth.com/?ref=583095</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;http://monthlyyouth.com/?ref=583095&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/1428123965971172484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2014/10/httpmonthlyyouthcomref583095.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/1428123965971172484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/1428123965971172484'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2014/10/httpmonthlyyouthcomref583095.html' title='http://monthlyyouth.com/?ref=583095'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-6996833160487651757</id><published>2009-08-13T10:51:00.001-07:00</published><updated>2009-08-13T10:51:53.489-07:00</updated><title type='text'></title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;998579&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;gmres&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Generalized Minimum Residual method (with restarts) &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;998582&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998583&quot;&gt;&lt;/a&gt;x = gmres(A,b)&lt;br /&gt;&lt;a name=&quot;998584&quot;&gt;&lt;/a&gt;gmres(A,b,restart)&lt;br /&gt;&lt;a name=&quot;998585&quot;&gt;&lt;/a&gt;gmres(A,b,restart,tol)&lt;br /&gt;&lt;a name=&quot;998586&quot;&gt;&lt;/a&gt;gmres(A,b,restart,tol,maxit)&lt;br /&gt;&lt;a name=&quot;998587&quot;&gt;&lt;/a&gt;gmres(A,b,restart,tol,maxit,M)&lt;br /&gt;&lt;a name=&quot;998588&quot;&gt;&lt;/a&gt;gmres(A,b,restart,tol,maxit,M1,M2)&lt;br /&gt;&lt;a name=&quot;998589&quot;&gt;&lt;/a&gt;gmres(A,b,restart,tol,maxit,M1,M2,x0)&lt;br /&gt;&lt;a name=&quot;998590&quot;&gt;&lt;/a&gt;gmres(afun,b,restart,tol,maxit,m1fun,m2fun,x0,p1,p2,...)&lt;br /&gt;&lt;a name=&quot;998591&quot;&gt;&lt;/a&gt;[x,flag] = gmres(A,b,...)&lt;br /&gt;&lt;a name=&quot;998592&quot;&gt;&lt;/a&gt;[x,flag,relres] = gmres(A,b,...)&lt;br /&gt;&lt;a name=&quot;998593&quot;&gt;&lt;/a&gt;[x,flag,relres,iter] = gmres(A,b,...)&lt;br /&gt;&lt;a name=&quot;998594&quot;&gt;&lt;/a&gt;[x,flag,relres,iter,resvec] = gmres(A,b,...)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;998595&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;998596&quot;&gt;&lt;/a&gt;&lt;code&gt;x = gmres(A,b) &lt;/code&gt; &lt;a name=&quot;998597&quot;&gt;&lt;/a&gt;attempts to solve the system of linear equations &lt;code&gt;A*x = b&lt;/code&gt; for &lt;code&gt;x&lt;/code&gt;.  The &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; coefficient matrix &lt;code&gt;A&lt;/code&gt; must be square and should be large and sparse. The column vector &lt;code&gt;b&lt;/code&gt; must have length &lt;code&gt;n&lt;/code&gt;. &lt;code&gt;A&lt;/code&gt; can be a function &lt;code&gt;afun&lt;/code&gt; such that &lt;code&gt;afun(x)&lt;/code&gt; returns &lt;code&gt;A*x&lt;/code&gt;. For this syntax, &lt;code&gt;gmres&lt;/code&gt; does not restart; the maximum number of iterations is &lt;code&gt;min(n,10)&lt;/code&gt;. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998598&quot;&gt;&lt;/a&gt;If &lt;code&gt;gmres&lt;/code&gt; converges, a message to that effect is displayed. If &lt;code&gt;gmres&lt;/code&gt; fails to converge after the maximum number of iterations or halts for any reason, a warning message is printed displaying the relative residual &lt;code&gt;norm(b-A*x)/norm(b)&lt;/code&gt; and the iteration number at which the method stopped or failed.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998599&quot;&gt;&lt;/a&gt;&lt;code&gt;gmres(A,b,restart) &lt;/code&gt; &lt;a name=&quot;998600&quot;&gt;&lt;/a&gt;restarts the method every &lt;code&gt;restart&lt;/code&gt; inner iterations.  The maximum number of outer iterations is &lt;code&gt;min(n/restart,10)&lt;/code&gt;. The maximum number of total iterations is &lt;code&gt;restart*min(n/restart,10)&lt;/code&gt;. If &lt;code&gt;restart&lt;/code&gt; is &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;[]&lt;/code&gt;, then &lt;code&gt;gmres&lt;/code&gt; does not restart and the maximum number of total iterations is &lt;code&gt;min(n,10)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998601&quot;&gt;&lt;/a&gt;&lt;code&gt;gmres(A,b,restart,tol) &lt;/code&gt; &lt;a name=&quot;998602&quot;&gt;&lt;/a&gt;specifies the tolerance of the method.  If &lt;code&gt;tol&lt;/code&gt; is &lt;code&gt;[]&lt;/code&gt;, then &lt;code&gt;gmres&lt;/code&gt; uses the default, &lt;code&gt;1e-6&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998603&quot;&gt;&lt;/a&gt;&lt;code&gt;gmres(A,b,restart,tol,maxit) &lt;/code&gt; &lt;a name=&quot;1004639&quot;&gt;&lt;/a&gt;specifies the maximum number of outer iterations, i.e., the total number of iterations does not exceed &lt;code&gt;restart*maxit&lt;/code&gt;.  If &lt;code&gt;maxit&lt;/code&gt; is &lt;code&gt;[]&lt;/code&gt; then &lt;code&gt;gmres&lt;/code&gt; uses the default, &lt;code&gt;min(n/restart,10)&lt;/code&gt;. If &lt;code&gt;restart&lt;/code&gt; is &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;[]&lt;/code&gt;, then the maximum number of total iterations is &lt;code&gt;maxit&lt;/code&gt; (instead of &lt;code&gt;restart*maxit&lt;/code&gt;).&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998605&quot;&gt;&lt;/a&gt;&lt;code&gt;gmres(A,b,restart,tol,maxit,M)&lt;span style=&quot;font-family:sansserif;&quot;&gt; and  &lt;/span&gt;gmres(A,b,restart,tol,maxit,M1,M2) &lt;/code&gt; &lt;a name=&quot;998606&quot;&gt;&lt;/a&gt;use preconditioner &lt;code&gt;M&lt;/code&gt; or &lt;code&gt;M = M1*M2&lt;/code&gt; and effectively solve the system &lt;code&gt;inv(M)*A*x = inv(M)*b&lt;/code&gt; for &lt;code&gt;x&lt;/code&gt;.  If &lt;code&gt;M&lt;/code&gt; is &lt;code&gt;[]&lt;/code&gt; then &lt;code&gt;gmres&lt;/code&gt; applies no preconditioner.   &lt;code&gt;M&lt;/code&gt; can be a function that returns &lt;code&gt;M\x&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998607&quot;&gt;&lt;/a&gt;&lt;code&gt;gmres(A,b,restart,tol,maxit,M1,M2,x0) &lt;/code&gt; &lt;a name=&quot;998608&quot;&gt;&lt;/a&gt;specifies the first initial guess.  If &lt;code&gt;x0&lt;/code&gt; is &lt;code&gt;[]&lt;/code&gt;, then &lt;code&gt;gmres&lt;/code&gt; uses the default, an all-zero vector.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998609&quot;&gt;&lt;/a&gt;&lt;code&gt;gmres(afun,b,restart,tol,maxit,m1fun,m2fun,x0,p1,p2,...) &lt;/code&gt; &lt;a name=&quot;998610&quot;&gt;&lt;/a&gt;passes parameters to functions &lt;code&gt;afun(x,p1,p2,...)&lt;/code&gt;, &lt;code&gt;m1fun(x,p1,p2,...)&lt;/code&gt;, and &lt;code&gt;m2fun(x,p1,p2,...)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998611&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,flag] = gmres(A,b,&lt;code&gt;...&lt;/code&gt;) &lt;/code&gt; &lt;a name=&quot;998633&quot;&gt;&lt;/a&gt;also returns a convergence flag:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1003294&quot;&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;998618&quot;&gt;&lt;/a&gt;&lt;code&gt;flag = 0&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;998620&quot;&gt;&lt;/a&gt;&lt;code&gt;gmres&lt;/code&gt; converged to the desired tolerance &lt;code&gt;tol&lt;/code&gt; within &lt;code&gt;maxit&lt;/code&gt; outer iterations.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;998622&quot;&gt;&lt;/a&gt;&lt;code&gt;flag = 1&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;998624&quot;&gt;&lt;/a&gt;&lt;code&gt;gmres&lt;/code&gt; iterated &lt;code&gt;maxit&lt;/code&gt; times but did not converge.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;998626&quot;&gt;&lt;/a&gt;&lt;code&gt;flag = 2&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;998628&quot;&gt;&lt;/a&gt;Preconditioner &lt;code&gt;M&lt;/code&gt; was ill-conditioned.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;998630&quot;&gt;&lt;/a&gt;&lt;code&gt;flag = 3&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;998632&quot;&gt;&lt;/a&gt;&lt;code&gt;gmres&lt;/code&gt; stagnated. (Two consecutive iterates were the same.)&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998634&quot;&gt;&lt;/a&gt;Whenever &lt;code&gt;flag&lt;/code&gt; is not &lt;code&gt;0&lt;/code&gt;, the solution &lt;code&gt;x&lt;/code&gt; returned is that with minimal norm residual computed over all the iterations. No messages are displayed if the &lt;code&gt;flag&lt;/code&gt; output is specified.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998635&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,flag,relres] = gmres(A,b&lt;code&gt;,...&lt;/code&gt;) &lt;/code&gt; &lt;a name=&quot;998636&quot;&gt;&lt;/a&gt;also returns the relative residual &lt;code&gt;norm(b-A*x)/norm(b)&lt;/code&gt;.  If &lt;code&gt;flag&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;relres &lt;= tol&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998637&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,flag,relres,iter] = gmres(A,b,&lt;code&gt;...&lt;/code&gt;) &lt;/code&gt; &lt;a name=&quot;998638&quot;&gt;&lt;/a&gt;also returns both the outer and inner iteration numbers at which &lt;code&gt;x&lt;/code&gt; was computed, where &lt;code&gt;0 &lt;= iter(1) &lt;= maxit&lt;/code&gt; and &lt;code&gt;0 &lt;= iter(2) &lt;= restart&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998639&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,flag,relres,iter,resvec] = gmres(A,b&lt;code&gt;,...&lt;/code&gt;) &lt;/code&gt; &lt;a name=&quot;998640&quot;&gt;&lt;/a&gt;also returns a vector of the residual norms at each inner iteration, including &lt;code&gt;norm(b-A*x0)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;998641&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;998642&quot;&gt;&lt;/a&gt;&lt;strong&gt;Example 1&lt;/strong&gt;.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998643&quot;&gt;&lt;/a&gt;A = gallery(&#39;wilk&#39;,21); &lt;br /&gt;&lt;a name=&quot;998644&quot;&gt;&lt;/a&gt;b = sum(A,2);&lt;br /&gt;&lt;a name=&quot;998645&quot;&gt;&lt;/a&gt;tol = 1e-12; &lt;br /&gt;&lt;a name=&quot;998646&quot;&gt;&lt;/a&gt;maxit = 15;&lt;br /&gt;&lt;a name=&quot;998647&quot;&gt;&lt;/a&gt;M1 = diag([10:-1:1 1 1:10]);&lt;br /&gt;&lt;a name=&quot;998648&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;998649&quot;&gt;&lt;/a&gt;x = gmres(A,b,10,tol,maxit,M1,[],[]);&lt;br /&gt;&lt;a name=&quot;998650&quot;&gt;&lt;/a&gt;gmres(10) converged at iteration 2(10) to a solution with relative&lt;br /&gt;residual 1.9e-013&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998651&quot;&gt;&lt;/a&gt;Alternatively, use this matrix-vector product function&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998652&quot;&gt;&lt;/a&gt;function y = afun(x,n)&lt;br /&gt;&lt;a name=&quot;998653&quot;&gt;&lt;/a&gt;y = [0;&lt;br /&gt;&lt;a name=&quot;998654&quot;&gt;&lt;/a&gt;     x(1:n-1)] + [((n-1)/2:-1:0)&#39;;&lt;br /&gt;&lt;a name=&quot;998655&quot;&gt;&lt;/a&gt;     (1:(n-1)/2)&#39;] .&lt;code&gt;*&lt;/code&gt;x + [x(2:n);&lt;br /&gt;&lt;a name=&quot;998656&quot;&gt;&lt;/a&gt;     0];&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998657&quot;&gt;&lt;/a&gt;and this preconditioner backsolve function&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998658&quot;&gt;&lt;/a&gt;function y = mfun(r,n)&lt;br /&gt;&lt;a name=&quot;998659&quot;&gt;&lt;/a&gt;y = r ./ [((n-1)/2:-1:1)&#39;; 1; (1:(n-1)/2)&#39;];&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998660&quot;&gt;&lt;/a&gt;as inputs to &lt;code&gt;gmres&lt;/code&gt;&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998661&quot;&gt;&lt;/a&gt;x1 = gmres(@afun,b,10,tol,maxit,@mfun,[],[],21);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998662&quot;&gt;&lt;/a&gt;Note that both &lt;code&gt;afun&lt;/code&gt; and &lt;code&gt;mfun&lt;/code&gt; must accept the &lt;code&gt;gmres&lt;/code&gt; extra input &lt;code&gt;n=21&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998663&quot;&gt;&lt;/a&gt;&lt;strong&gt;Example 2&lt;/strong&gt;.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998664&quot;&gt;&lt;/a&gt;load west0479&lt;br /&gt;&lt;a name=&quot;998665&quot;&gt;&lt;/a&gt;A = west0479&lt;br /&gt;&lt;a name=&quot;998666&quot;&gt;&lt;/a&gt;b = sum(A,2)&lt;br /&gt;&lt;a name=&quot;998667&quot;&gt;&lt;/a&gt;[x,flag] = gmres(A,b,5)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998668&quot;&gt;&lt;/a&gt;&lt;code&gt;flag &lt;/code&gt;is &lt;code&gt;1&lt;/code&gt; because &lt;code&gt;gmres&lt;/code&gt; does not converge to the default tolerance &lt;code&gt;1e-6&lt;/code&gt; within the default 10 outer iterations.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998669&quot;&gt;&lt;/a&gt;[L1,U1] = luinc(A,1e-5);&lt;br /&gt;&lt;a name=&quot;998670&quot;&gt;&lt;/a&gt;[x1,flag1] = gmres(A,b,5,1e-6,5,L1,U1);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998671&quot;&gt;&lt;/a&gt;&lt;code&gt;flag1&lt;/code&gt; is&lt;code&gt; 2&lt;/code&gt; because the upper triangular &lt;code&gt;U1&lt;/code&gt; has a zero on its diagonal, and &lt;code&gt;gmres&lt;/code&gt; fails in the first iteration when it tries to solve a system such as &lt;code&gt;U1*y = r&lt;/code&gt; for &lt;code&gt;y&lt;/code&gt; using backslash.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998672&quot;&gt;&lt;/a&gt;[L2,U2] = luinc(A,1e-6);&lt;br /&gt;&lt;a name=&quot;998673&quot;&gt;&lt;/a&gt;tol = 1e-15;&lt;br /&gt;&lt;a name=&quot;998674&quot;&gt;&lt;/a&gt;[x4,flag4,relres4,iter4,resvec4] = gmres(A,b,4,tol,5,L2,U2);&lt;br /&gt;&lt;a name=&quot;998675&quot;&gt;&lt;/a&gt;[x6,flag6,relres6,iter6,resvec6] = gmres(A,b,6,tol,3,L2,U2);&lt;br /&gt;&lt;a name=&quot;998676&quot;&gt;&lt;/a&gt;[x8,flag8,relres8,iter8,resvec8] = gmres(A,b,8,tol,3,L2,U2);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998677&quot;&gt;&lt;/a&gt;&lt;code&gt;flag4&lt;/code&gt;, &lt;code&gt;flag6&lt;/code&gt;, and &lt;code&gt;flag8&lt;/code&gt; are all &lt;code&gt;0&lt;/code&gt; because &lt;code&gt;gmres&lt;/code&gt; converged when restarted at iterations 4, 6, and 8 while preconditioned by the incomplete LU factorization with a drop tolerance of &lt;code&gt;1e-6&lt;/code&gt;. This is verified by the plots of outer iteration number against relative residual. A combined plot of all three clearly shows the restarting at iterations 4 and 6. The total number of iterations computed may be more for lower values of &lt;code&gt;restart&lt;/code&gt;, but the number of length &lt;code&gt;n&lt;/code&gt; vectors stored is fewer, and the amount of work done in the method decreases proportionally.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998681&quot;&gt;&lt;/a&gt; &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g4a.gif&quot; align=&quot;bottom&quot; /&gt;&lt;/p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;998579&quot;&gt; &lt;!-- FNAME:gmres --&gt;&lt;/a&gt;&lt;a name=&quot;998579&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;998580&quot;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/6996833160487651757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/gmres-generalized-minimum-residual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/6996833160487651757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/6996833160487651757'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/gmres-generalized-minimum-residual.html' title=''/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-5486460417255216706</id><published>2009-08-13T10:49:00.000-07:00</published><updated>2009-08-13T10:50:41.219-07:00</updated><title type='text'></title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;103986&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;global&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Define a global variable &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;103989&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;103990&quot;&gt;&lt;/a&gt;global X Y Z&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;103991&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;103992&quot;&gt;&lt;/a&gt;&lt;code&gt;global X Y Z &lt;/code&gt; &lt;a name=&quot;580897&quot;&gt;&lt;/a&gt;defines &lt;code&gt;X&lt;/code&gt;, &lt;code&gt;Y&lt;/code&gt;, and &lt;code&gt;Z&lt;/code&gt; as global in scope.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;103993&quot;&gt;&lt;/a&gt;Ordinarily, each MATLAB function, defined by an M-file, has its own local variables, which are separate from those of other functions, and from those of the base workspace. However, if several functions, and possibly the base workspace,&lt;span style=&quot;font-family:sansserif;&quot;&gt; all d&lt;/span&gt;eclare a particular name as global, they all share a single copy of that variable. Any assignment to that variable, in any function, is available to all the functions declaring it global.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;991408&quot;&gt;&lt;/a&gt;If the global variable does not exist the first time you issue the &lt;code&gt;global&lt;/code&gt; statement, it is initialized to the empty matrix. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;991423&quot;&gt;&lt;/a&gt;If a variable with the same name as the global variable already exists in the current workspace, MATLAB issues a warning and changes the value of that variable to match the global.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;509784&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;828467&quot;&gt;&lt;/a&gt;Use &lt;code&gt;clear globa&lt;/code&gt;l &lt;code&gt;&lt;em&gt;variable&lt;/em&gt;&lt;/code&gt; to clear a global variable from the global workspace. Use &lt;code&gt;clear&lt;/code&gt; &lt;code&gt;&lt;em&gt;variable&lt;/em&gt;&lt;/code&gt; to clear the global link from the current workspace without affecting the value of the global.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;843871&quot;&gt;&lt;/a&gt;To use a global within a callback, declare the global, use it, then clear the global link from the workspace. This avoids declaring the global after it has been referenced. For example,&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;843872&quot;&gt;&lt;/a&gt;&lt;code&gt;uicontrol(&#39;style&#39;,&#39;pushbutton&#39;,&#39;CallBack&#39;,...&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;844022&quot;&gt;&lt;/a&gt;&lt;code&gt;&#39;global MY_GLOBAL,disp(MY_GLOBAL),MY_GLOBAL = MY_GLOBAL+1,clear MY_GLOBAL&#39;,...&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;844063&quot;&gt;&lt;/a&gt;&lt;code&gt;&#39;string&#39;,&#39;count&#39;)&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1006268&quot;&gt;&lt;/a&gt;There is no function form of the global command (i.e., you cannot use parentheses and quote the variable names).&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;995424&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;995425&quot;&gt;&lt;/a&gt;Here is the code for the functions &lt;code&gt;tic&lt;/code&gt; and &lt;code&gt;toc&lt;/code&gt; (some comments abridged). These functions manipulate a stopwatch-like timer. The global variable &lt;code&gt;TICTOC&lt;/code&gt; is shared by the two functions, but it is invisible in the base workspace or in any other functions that do not declare it.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;103997&quot;&gt;&lt;/a&gt;function tic&lt;br /&gt;&lt;a name=&quot;103998&quot;&gt;&lt;/a&gt;%    TIC Start a stopwatch timer.&lt;br /&gt;&lt;a name=&quot;104000&quot;&gt;&lt;/a&gt;%        TIC; any stuff; TOC&lt;br /&gt;&lt;a name=&quot;104003&quot;&gt;&lt;/a&gt;%    prints the time required.&lt;br /&gt;&lt;a name=&quot;104004&quot;&gt;&lt;/a&gt;%    See also: TOC, CLOCK.&lt;br /&gt;&lt;a name=&quot;104005&quot;&gt;&lt;/a&gt;global TICTOC&lt;br /&gt;&lt;a name=&quot;104006&quot;&gt;&lt;/a&gt;TICTOC = clock;&lt;br /&gt;&lt;a name=&quot;809720&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;104007&quot;&gt;&lt;/a&gt;function t = toc&lt;br /&gt;&lt;a name=&quot;104008&quot;&gt;&lt;/a&gt;%    TOC Read the stopwatch timer.&lt;br /&gt;&lt;a name=&quot;104009&quot;&gt;&lt;/a&gt;%    TOC prints the elapsed time since TIC was used.&lt;br /&gt;&lt;a name=&quot;104010&quot;&gt;&lt;/a&gt;%    t = TOC; saves elapsed time in t, does not print.&lt;br /&gt;&lt;a name=&quot;104011&quot;&gt;&lt;/a&gt;%    See also: TIC, ETIME.&lt;br /&gt;&lt;a name=&quot;104012&quot;&gt;&lt;/a&gt;global TICTOC&lt;br /&gt;&lt;a name=&quot;104013&quot;&gt;&lt;/a&gt;if nargout &lt; 1&lt;br /&gt;&lt;a name=&quot;104014&quot;&gt;&lt;/a&gt;    elapsed_time = etime(clock,TICTOC)&lt;br /&gt;&lt;a name=&quot;104015&quot;&gt;&lt;/a&gt;else&lt;br /&gt;&lt;a name=&quot;104016&quot;&gt;&lt;/a&gt;    t = etime(clock,TICTOC);&lt;br /&gt;&lt;a name=&quot;104017&quot;&gt;&lt;/a&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;103986&quot;&gt; &lt;!-- FNAME:global --&gt;&lt;/a&gt;&lt;a name=&quot;103986&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;579476&quot;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/5486460417255216706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/global-define-global-variable-syntax.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/5486460417255216706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/5486460417255216706'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/global-define-global-variable-syntax.html' title=''/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-2574516865394468138</id><published>2009-08-13T10:48:00.001-07:00</published><updated>2009-08-13T10:49:12.897-07:00</updated><title type='text'></title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;469031&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;ginput&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Input data using the mouse  &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;260986&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;260987&quot;&gt;&lt;/a&gt;[x,y] = ginput(n)&lt;br /&gt;&lt;a name=&quot;260988&quot;&gt;&lt;/a&gt;[x,y] = ginput&lt;br /&gt;&lt;a name=&quot;260989&quot;&gt;&lt;/a&gt;[x,y,button] = ginput(...)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;260997&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;260998&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;ginput &lt;/code&gt;&lt;/code&gt; &lt;a name=&quot;493896&quot;&gt;&lt;/a&gt;enables you to select points from the figure using the mouse or arrow keys for cursor positioning. The figure must have focus before &lt;code&gt;ginput&lt;/code&gt; receives input.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;260999&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,y] = ginput(n) &lt;/code&gt; &lt;a name=&quot;486879&quot;&gt;&lt;/a&gt;enables you to select &lt;code&gt;n&lt;/code&gt; points from the current axes and returns the &lt;em&gt;x&lt;/em&gt;- and &lt;em&gt;y&lt;/em&gt;-coordinates in the column vectors &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;, respectively. You can press the &lt;strong&gt;Return&lt;/strong&gt; key to terminate the input before entering &lt;code&gt;n&lt;/code&gt; points.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;261000&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,y] = ginput &lt;/code&gt; &lt;a name=&quot;486891&quot;&gt;&lt;/a&gt;gathers an unlimited number of points until you press the &lt;strong&gt;Return&lt;/strong&gt; key.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;261001&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,y,button] = ginput(...) &lt;/code&gt; &lt;a name=&quot;486903&quot;&gt;&lt;/a&gt;returns the &lt;em&gt;x&lt;/em&gt;-coordinates, the &lt;em&gt;y&lt;/em&gt;-coordinates, and the button or key designation. &lt;code&gt;button&lt;/code&gt; is a vector of integers indicating which mouse buttons you pressed (1 for left, 2 for middle, 3 for right), or ASCII numbers indicating which keys on the keyboard you pressed.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;698585&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;698586&quot;&gt;&lt;/a&gt;If you select points from multiple axes, the results you get are relative to those axes coordinates systems.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;261002&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;261003&quot;&gt;&lt;/a&gt;Pick 10 two-dimensional points from the figure window.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;261004&quot;&gt;&lt;/a&gt;[x,y] = ginput(10)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;261005&quot;&gt;&lt;/a&gt;Position the cursor with the mouse (or the arrow keys on terminals without a mouse, such as Tektronix emulators). Enter data points by pressing a mouse button or a key on the keyboard. To terminate input before entering 10 points, press the &lt;strong&gt;Return&lt;/strong&gt; key.&lt;/p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;469031&quot;&gt; &lt;!-- FNAME:ginput --&gt;&lt;/a&gt;&lt;a name=&quot;469031&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;491620&quot;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/2574516865394468138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/ginput-input-data-using-mouse-syntax-xy_13.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/2574516865394468138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/2574516865394468138'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/ginput-input-data-using-mouse-syntax-xy_13.html' title=''/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-4288337872445829341</id><published>2009-08-13T10:48:00.000-07:00</published><updated>2009-08-13T10:49:06.964-07:00</updated><title type='text'></title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;469031&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;ginput&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Input data using the mouse  &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;260986&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;260987&quot;&gt;&lt;/a&gt;[x,y] = ginput(n)&lt;br /&gt;&lt;a name=&quot;260988&quot;&gt;&lt;/a&gt;[x,y] = ginput&lt;br /&gt;&lt;a name=&quot;260989&quot;&gt;&lt;/a&gt;[x,y,button] = ginput(...)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;260997&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;260998&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;ginput &lt;/code&gt;&lt;/code&gt; &lt;a name=&quot;493896&quot;&gt;&lt;/a&gt;enables you to select points from the figure using the mouse or arrow keys for cursor positioning. The figure must have focus before &lt;code&gt;ginput&lt;/code&gt; receives input.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;260999&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,y] = ginput(n) &lt;/code&gt; &lt;a name=&quot;486879&quot;&gt;&lt;/a&gt;enables you to select &lt;code&gt;n&lt;/code&gt; points from the current axes and returns the &lt;em&gt;x&lt;/em&gt;- and &lt;em&gt;y&lt;/em&gt;-coordinates in the column vectors &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;, respectively. You can press the &lt;strong&gt;Return&lt;/strong&gt; key to terminate the input before entering &lt;code&gt;n&lt;/code&gt; points.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;261000&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,y] = ginput &lt;/code&gt; &lt;a name=&quot;486891&quot;&gt;&lt;/a&gt;gathers an unlimited number of points until you press the &lt;strong&gt;Return&lt;/strong&gt; key.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;261001&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,y,button] = ginput(...) &lt;/code&gt; &lt;a name=&quot;486903&quot;&gt;&lt;/a&gt;returns the &lt;em&gt;x&lt;/em&gt;-coordinates, the &lt;em&gt;y&lt;/em&gt;-coordinates, and the button or key designation. &lt;code&gt;button&lt;/code&gt; is a vector of integers indicating which mouse buttons you pressed (1 for left, 2 for middle, 3 for right), or ASCII numbers indicating which keys on the keyboard you pressed.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;698585&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;698586&quot;&gt;&lt;/a&gt;If you select points from multiple axes, the results you get are relative to those axes coordinates systems.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;261002&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;261003&quot;&gt;&lt;/a&gt;Pick 10 two-dimensional points from the figure window.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;261004&quot;&gt;&lt;/a&gt;[x,y] = ginput(10)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;261005&quot;&gt;&lt;/a&gt;Position the cursor with the mouse (or the arrow keys on terminals without a mouse, such as Tektronix emulators). Enter data points by pressing a mouse button or a key on the keyboard. To terminate input before entering 10 points, press the &lt;strong&gt;Return&lt;/strong&gt; key.&lt;/p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;469031&quot;&gt; &lt;!-- FNAME:ginput --&gt;&lt;/a&gt;&lt;a name=&quot;469031&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;491620&quot;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/4288337872445829341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/ginput-input-data-using-mouse-syntax-xy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/4288337872445829341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/4288337872445829341'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/ginput-input-data-using-mouse-syntax-xy.html' title=''/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-6981058572983741274</id><published>2009-08-13T10:45:00.000-07:00</published><updated>2009-08-13T10:48:07.645-07:00</updated><title type='text'></title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;376005&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;get (timer)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Display or get timer object properties &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;376008&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;376009&quot;&gt;&lt;/a&gt;get(obj)&lt;br /&gt;&lt;a name=&quot;431107&quot;&gt;&lt;/a&gt;out = get(obj)&lt;br /&gt;&lt;a name=&quot;386009&quot;&gt;&lt;/a&gt;out = get(obj,&#39;&lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt;&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;376010&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;544170&quot;&gt;&lt;/a&gt;&lt;code&gt;get(obj) &lt;/code&gt; &lt;a name=&quot;544186&quot;&gt;&lt;/a&gt;displays all property names and their current values for timer object &lt;code&gt;obj&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;544172&quot;&gt;&lt;/a&gt;&lt;code&gt;V = get(obj) &lt;/code&gt; &lt;a name=&quot;544200&quot;&gt;&lt;/a&gt;returns a structure, &lt;code&gt;V&lt;/code&gt;, where each field name is the name of a property of &lt;code&gt;obj&lt;/code&gt; and each field contains the value of that property.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;544122&quot;&gt;&lt;/a&gt;&lt;code&gt;V = get(obj,&#39;&lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt;&#39;) &lt;/code&gt; &lt;a name=&quot;544789&quot;&gt;&lt;/a&gt;returns the value, &lt;code&gt;V&lt;/code&gt;, of the timer object property specified in &lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt;. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;544125&quot;&gt;&lt;/a&gt;If &lt;code&gt;PropertyName&lt;/code&gt; is a1-by-N or N-by-1 cell array of strings containing property names, &lt;code&gt;V&lt;/code&gt; is a 1-by-N cell array of values. If &lt;code&gt;obj&lt;/code&gt; is a vector of timer objects, &lt;code&gt;V&lt;/code&gt; is an M-by-N cell array of property values where M is equal to the length of &lt;code&gt;obj&lt;/code&gt; and N is equal to the number of properties specified.&lt;/p&gt; &lt;a name=&quot;example&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;544138&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;544139&quot;&gt;&lt;/a&gt;t = timer;&lt;br /&gt;&lt;a name=&quot;551854&quot;&gt;&lt;/a&gt;get(t)&lt;br /&gt;&lt;a name=&quot;551855&quot;&gt;&lt;/a&gt;    AveragePeriod: NaN&lt;br /&gt;&lt;a name=&quot;551856&quot;&gt;&lt;/a&gt;         BusyMode: &#39;drop&#39;&lt;br /&gt;&lt;a name=&quot;551857&quot;&gt;&lt;/a&gt;         ErrorFcn: []&lt;br /&gt;&lt;a name=&quot;551858&quot;&gt;&lt;/a&gt;    ExecutionMode: &#39;singleShot&#39;&lt;br /&gt;&lt;a name=&quot;551859&quot;&gt;&lt;/a&gt;    InstantPeriod: NaN&lt;br /&gt;&lt;a name=&quot;551860&quot;&gt;&lt;/a&gt;        LastError: &#39;none&#39;&lt;br /&gt;&lt;a name=&quot;551861&quot;&gt;&lt;/a&gt;             Name: &#39;timer-1&#39;&lt;br /&gt;&lt;a name=&quot;551862&quot;&gt;&lt;/a&gt;           Period: 1&lt;br /&gt;&lt;a name=&quot;551863&quot;&gt;&lt;/a&gt;          Running: &#39;off&#39;&lt;br /&gt;&lt;a name=&quot;551864&quot;&gt;&lt;/a&gt;       StartDelay: 0&lt;br /&gt;&lt;a name=&quot;551865&quot;&gt;&lt;/a&gt;         StartFcn: []&lt;br /&gt;&lt;a name=&quot;551866&quot;&gt;&lt;/a&gt;          StopFcn: []&lt;br /&gt;&lt;a name=&quot;551867&quot;&gt;&lt;/a&gt;              Tag: &#39;&#39;&lt;br /&gt;&lt;a name=&quot;551868&quot;&gt;&lt;/a&gt;   TasksToExecute: Inf&lt;br /&gt;&lt;a name=&quot;551869&quot;&gt;&lt;/a&gt;    TasksExecuted: 0&lt;br /&gt;&lt;a name=&quot;551870&quot;&gt;&lt;/a&gt;         TimerFcn: []&lt;br /&gt;&lt;a name=&quot;551871&quot;&gt;&lt;/a&gt;             Type: &#39;timer&#39;&lt;br /&gt;&lt;a name=&quot;544307&quot;&gt;&lt;/a&gt;         UserData: []&lt;br /&gt;&lt;a name=&quot;551852&quot;&gt;&lt;/a&gt;get(t, {&#39;StartDelay&#39;,&#39;Period&#39;})&lt;br /&gt;&lt;a name=&quot;551846&quot;&gt;&lt;/a&gt;ans =&lt;br /&gt;&lt;a name=&quot;551847&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;551844&quot;&gt;&lt;/a&gt;    [0]    [1]&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;13763&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;getappdata&lt;/span&gt;   &lt;!-- FNAME:getappdata --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;13763&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;13764&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;a name=&quot;13765&quot;&gt;&lt;/a&gt;Get value of application-defined data&lt;/p&gt; &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;13766&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;13767&quot;&gt;&lt;/a&gt;value = getappdata(h,name)&lt;br /&gt;&lt;a name=&quot;13768&quot;&gt;&lt;/a&gt;values = getappdata(h)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;13769&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;13770&quot;&gt;&lt;/a&gt;&lt;code&gt;value = getappdata(h,name) &lt;/code&gt; &lt;a name=&quot;13771&quot;&gt;&lt;/a&gt;gets the value of the application-defined data with the name specified by &lt;code&gt;name&lt;/code&gt;, in the object with the handle &lt;code&gt;h&lt;/code&gt;. If the application-defined data does not exist, MATLAB returns an empty matrix in &lt;code&gt;value&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;13772&quot;&gt;&lt;/a&gt;&lt;code&gt;value = getappdata(h) &lt;/code&gt; &lt;a name=&quot;13773&quot;&gt;&lt;/a&gt;returns all application-defined data for the object with handle &lt;code&gt;h&lt;/code&gt;. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;1036150&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;getenv&lt;/span&gt;   &lt;!-- FNAME:getenv --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;1036150&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;1026411&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;a name=&quot;1026412&quot;&gt;&lt;/a&gt; Get environment variable&lt;/p&gt; &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;1026769&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1026770&quot;&gt;&lt;/a&gt;getenv &#39;name&#39;&lt;br /&gt;&lt;a name=&quot;1026785&quot;&gt;&lt;/a&gt;N = getenv(&#39;name&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;1026771&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1026772&quot;&gt;&lt;/a&gt;&lt;code&gt;getenv &#39;name&#39; &lt;/code&gt; &lt;a name=&quot;1026786&quot;&gt;&lt;/a&gt;searches the underlying operating system&#39;s environment list for a string of the form &lt;code&gt;name=value&lt;/code&gt;, where &lt;code&gt;name&lt;/code&gt; is the input string. If found, MATLAB returns the string, &lt;code&gt;value&lt;/code&gt;. If the specified name cannot be found, an empty matrix is returned.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1026787&quot;&gt;&lt;/a&gt;&lt;code&gt;N = getenv(&#39;name&#39;) &lt;/code&gt; &lt;a name=&quot;1026788&quot;&gt;&lt;/a&gt;returns &lt;code&gt;value&lt;/code&gt; to the variable, &lt;code&gt;N&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;1026773&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1026807&quot;&gt;&lt;/a&gt;os = getenv(&#39;OS&#39;)&lt;br /&gt;&lt;a name=&quot;1026808&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;1026809&quot;&gt;&lt;/a&gt;os =&lt;br /&gt;&lt;a name=&quot;1026811&quot;&gt;&lt;/a&gt;Windows_NT&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;663733&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;getfield&lt;/span&gt;   &lt;!-- FNAME:getfield --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;663733&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;663768&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;a name=&quot;664485&quot;&gt;&lt;/a&gt; Get field of structure array&lt;/p&gt; &lt;ul&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr width=&quot;90%&quot;&gt;&lt;td bgcolor=&quot;#ffe4b0&quot;&gt;&lt;a name=&quot;1093255&quot;&gt;&lt;/a&gt;&lt;b&gt;Note  &lt;/b&gt;   &lt;code&gt;getfield&lt;/code&gt; is obsolete and will be removed in a future release. Please use &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_prog/ch13_ce5.html#dynamic_field_names&quot;&gt;dynamic field names&lt;/a&gt; instead. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/ul&gt; &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;665159&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;766650&quot;&gt;&lt;/a&gt;f = getfield(s,&#39;field&#39;)&lt;br /&gt;&lt;a name=&quot;665233&quot;&gt;&lt;/a&gt;f = getfield(s,{i,j},&#39;field&#39;,{k})&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;665348&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;766701&quot;&gt;&lt;/a&gt;&lt;code&gt;f = getfield(s,&#39;field&#39;)&lt;span style=&quot;font-family:sansserif;&quot;&gt;, &lt;/span&gt;&lt;/code&gt; &lt;a name=&quot;766702&quot;&gt;&lt;/a&gt;where &lt;code&gt;s&lt;/code&gt; is a 1-by-1 structure, returns the contents of the specified field. This is equivalent to the syntax &lt;code&gt;f = s.field&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1030387&quot;&gt;&lt;/a&gt;If &lt;code&gt;s&lt;/code&gt; is a structure having dimensions greater than 1-by-1, &lt;code&gt;getfield&lt;/code&gt; returns the first of all output values requested in the call. That is, for structure array &lt;code&gt;s(m,n)&lt;/code&gt;, &lt;code&gt;getfield&lt;/code&gt; returns &lt;code&gt;f&lt;/code&gt; &lt;code&gt;=&lt;/code&gt; &lt;code&gt;s(1,1).field&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;664490&quot;&gt;&lt;/a&gt;&lt;code&gt;f = getfield(s,{i,j},&#39;field&#39;,{k}) &lt;/code&gt; &lt;a name=&quot;665293&quot;&gt;&lt;/a&gt;returns the contents of the specified field. This is equivalent to the syntax &lt;code&gt;f = s(i,j).field(k)&lt;/code&gt;. All subscripts must be passed as cell arrays--that is, they must be enclosed in curly braces (similar to&lt;code&gt;{i,j}&lt;/code&gt; and &lt;code&gt;{k}&lt;/code&gt; above). Pass field references as strings. &lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;669104&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;669105&quot;&gt;&lt;/a&gt;Given the structure&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;766750&quot;&gt;&lt;/a&gt;mystr(1,1).name = &#39;alice&#39;;&lt;br /&gt;&lt;a name=&quot;766751&quot;&gt;&lt;/a&gt;mystr(1,1).ID = 0;&lt;br /&gt;&lt;a name=&quot;766752&quot;&gt;&lt;/a&gt;mystr(2,1).name = &#39;gertrude&#39;;&lt;br /&gt;&lt;a name=&quot;669107&quot;&gt;&lt;/a&gt;mystr(2,1).ID = 1&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;669258&quot;&gt;&lt;/a&gt;Then the command &lt;code&gt;f = getfield(mystr,{2,1},&#39;name&#39;)&lt;/code&gt; yields&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;669260&quot;&gt;&lt;/a&gt;f =&lt;br /&gt;&lt;a name=&quot;767036&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;669262&quot;&gt;&lt;/a&gt;gertrude&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;669473&quot;&gt;&lt;/a&gt;To list the contents of all name (or other) fields, embed &lt;code&gt;getfield&lt;/code&gt; in a loop.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;669518&quot;&gt;&lt;/a&gt;for k = 1:2&lt;br /&gt;&lt;a name=&quot;669611&quot;&gt;&lt;/a&gt;    name{k} = getfield(mystr,{k,1},&#39;name&#39;);&lt;br /&gt;&lt;a name=&quot;669634&quot;&gt;&lt;/a&gt;end&lt;br /&gt;&lt;a name=&quot;669679&quot;&gt;&lt;/a&gt;name&lt;br /&gt;&lt;a name=&quot;671946&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;767180&quot;&gt;&lt;/a&gt;name =&lt;br /&gt;&lt;a name=&quot;767181&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;669805&quot;&gt;&lt;/a&gt;    &#39;alice&#39;    &#39;gertrude&#39;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1036085&quot;&gt;&lt;/a&gt;The following example starts out by creating a structure using the standard structure syntax. It then reads the fields of the structure using &lt;code&gt;getfield&lt;/code&gt; with variable and quoted field names and additional subscripting arguments. &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1036040&quot;&gt;&lt;/a&gt;class = 5;     student = &#39;John_Doe&#39;;&lt;br /&gt;&lt;a name=&quot;1071405&quot;&gt;&lt;/a&gt;grades(class).John_Doe.Math(10,21:30) = ...&lt;br /&gt;&lt;a name=&quot;1071419&quot;&gt;&lt;/a&gt;             [85, 89, 76, 93, 85, 91, 68, 84, 95, 73];&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1036045&quot;&gt;&lt;/a&gt;Use &lt;code&gt;getfield&lt;/code&gt; to access the structure fields.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1036048&quot;&gt;&lt;/a&gt;getfield(grades,{class}, student, &#39;Math&#39;, {10,21:30})&lt;br /&gt;&lt;a name=&quot;1036049&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;1036050&quot;&gt;&lt;/a&gt;ans =&lt;br /&gt;&lt;a name=&quot;1036051&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;1036046&quot;&gt;&lt;/a&gt;    85    89    76    93    85    91    68    84    95    73&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;475320&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;getframe&lt;/span&gt;   &lt;!-- FNAME:getframe --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;475320&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;491604&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Get movie frame &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;352235&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;352236&quot;&gt;&lt;/a&gt;F = getframe&lt;br /&gt;&lt;a name=&quot;352237&quot;&gt;&lt;/a&gt;F = getframe(h)&lt;br /&gt;&lt;a name=&quot;352238&quot;&gt;&lt;/a&gt;F = getframe(h,rect)&lt;br /&gt;&lt;a name=&quot;403612&quot;&gt;&lt;/a&gt;[X,Map] = getframe(...)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;364458&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;352240&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;getframe &lt;/code&gt;&lt;/code&gt; &lt;a name=&quot;493342&quot;&gt;&lt;/a&gt;returns a movie frame. The frame is a snapshot (pixmap) of the current axes or figure. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;352241&quot;&gt;&lt;/a&gt;&lt;code&gt;F = getframe &lt;/code&gt; &lt;a name=&quot;486835&quot;&gt;&lt;/a&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;gets a frame from the current &lt;/span&gt;axes.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;450663&quot;&gt;&lt;/a&gt;&lt;code&gt;F = getframe(h) &lt;/code&gt; &lt;a name=&quot;486847&quot;&gt;&lt;/a&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;gets a frame from the &lt;/span&gt;figure&lt;span style=&quot;font-family:sansserif;&quot;&gt; or &lt;/span&gt;axes identified by the handle &lt;code&gt;h&lt;/code&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;352242&quot;&gt;&lt;/a&gt;&lt;code&gt;F = getframe(h,rect) &lt;/code&gt; &lt;a name=&quot;486859&quot;&gt;&lt;/a&gt;specifies a rectangular area from which to copy the pixmap. &lt;code&gt;rect&lt;/code&gt; is relative to the lower-left corner of &lt;span style=&quot;font-family:sansserif;&quot;&gt;the &lt;/span&gt;figure&lt;span style=&quot;font-family:sansserif;&quot;&gt; or &lt;/span&gt;axes &lt;code&gt;h&lt;/code&gt;, in pixel units. &lt;code&gt;rect&lt;/code&gt; is a four-element vector in the form &lt;code&gt;[left bottom width height]&lt;/code&gt;, where &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; define the dimensions of the rectangle.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;706702&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;F = getframe(...) &lt;/code&gt;&lt;/code&gt; &lt;a name=&quot;706704&quot;&gt;&lt;/a&gt;returns a movie frame, which is a structure having two fields:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;707202&quot;&gt;&lt;/a&gt;&lt;code&gt;cdata&lt;/code&gt; - The image data stored as a matrix of uint8 values. The dimensions of &lt;code&gt;F.cdata&lt;/code&gt; are height-by-width-by-3. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;707204&quot;&gt;&lt;/a&gt;&lt;code&gt;colormap&lt;/code&gt; - The colormap stored as an n-by-3 matrix of doubles. &lt;code&gt;F.colormap&lt;/code&gt; is empty on true color systems. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;706703&quot;&gt;&lt;/a&gt;To capture an image, use this approach:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;707551&quot;&gt;&lt;/a&gt;F = getframe(gcf);&lt;br /&gt;&lt;a name=&quot;707584&quot;&gt;&lt;/a&gt;image(F.cdata)&lt;br /&gt;&lt;a name=&quot;707601&quot;&gt;&lt;/a&gt;colormap(F.colormap)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;403901&quot;&gt;&lt;/a&gt;&lt;code&gt;[X,Map] = getframe(...) &lt;/code&gt; &lt;a name=&quot;486869&quot;&gt;&lt;/a&gt;returns the frame as an indexed image matrix &lt;code&gt;X&lt;/code&gt; and a colormap &lt;code&gt;Map&lt;/code&gt;. This version is obsolete and is supported only for compatibility with earlier version of MATLAB. Since indexed images cannot always capture true color displays, you should use the single output argument form of &lt;code&gt;getframe&lt;/code&gt;. To write code that is compatible with earlier version of MATLAB and that can take advantage of true color support, use the following approach:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;707805&quot;&gt;&lt;/a&gt;F = getframe(gcf);&lt;br /&gt;&lt;a name=&quot;707822&quot;&gt;&lt;/a&gt;[X,Map] = frame2im(f);&lt;br /&gt;&lt;a name=&quot;707831&quot;&gt;&lt;/a&gt;imshow(X,Map)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;449982&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;449983&quot;&gt;&lt;/a&gt;Usually, &lt;code&gt;getframe&lt;/code&gt; is used in a &lt;code&gt;for&lt;/code&gt; loop to assemble an array of movie frames for playback using &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/movie.html&quot;&gt;movie&lt;/a&gt;&lt;/code&gt;. For example,&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;706638&quot;&gt;&lt;/a&gt;for j = 1:n&lt;br /&gt;&lt;a name=&quot;706651&quot;&gt;&lt;/a&gt;    &lt;code&gt;&lt;em&gt;plotting commands&lt;br /&gt;&lt;/em&gt;&lt;/code&gt;&lt;a name=&quot;706656&quot;&gt;&lt;/a&gt;    F(j) = getframe;&lt;br /&gt;&lt;a name=&quot;706661&quot;&gt;&lt;/a&gt;end&lt;br /&gt;&lt;a name=&quot;706665&quot;&gt;&lt;/a&gt;movie(F)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;706689&quot;&gt;&lt;/a&gt;To create movies that are compatible with earlier versions of MATLAB (before Release 11/MATLAB 5.3) use this approach:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;706690&quot;&gt;&lt;/a&gt;M = moviein(n);&lt;br /&gt;&lt;a name=&quot;706691&quot;&gt;&lt;/a&gt;for j = 1:n&lt;br /&gt;&lt;a name=&quot;706694&quot;&gt;&lt;/a&gt;    &lt;code&gt;&lt;em&gt;plotting commands&lt;br /&gt;&lt;/em&gt;&lt;/code&gt;&lt;a name=&quot;706695&quot;&gt;&lt;/a&gt;    M(:,j) = getframe;&lt;br /&gt;&lt;a name=&quot;706696&quot;&gt;&lt;/a&gt;end&lt;br /&gt;&lt;a name=&quot;706697&quot;&gt;&lt;/a&gt;movie(M)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;capture_regions&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;706674&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;Capture Regions&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;671298&quot;&gt;&lt;/a&gt;Note that &lt;code&gt;F = getframe;&lt;/code&gt; returns the contents of the current axes, exclusive of the axis labels, title, or tick labels. &lt;code&gt;F = getframe(&lt;/code&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gcf.html&quot;&gt;gcf&lt;/a&gt;&lt;/code&gt;&lt;code&gt;);&lt;/code&gt; captures the entire interior of the current figure window. To capture the figure window menu, use the form &lt;code&gt;F = getframe(h,rect)&lt;/code&gt; with a rectangle sized to include the menu.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;352246&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;352247&quot;&gt;&lt;/a&gt;Make the &lt;code&gt;peaks&lt;/code&gt; function vibrate.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;352248&quot;&gt;&lt;/a&gt;&lt;code&gt;Z = peaks; surf(Z)&lt;br /&gt;&lt;/code&gt;&lt;a name=&quot;614437&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/axis.html&quot;&gt;axis&lt;/a&gt;&lt;/code&gt; tight&lt;br /&gt;&lt;a name=&quot;614438&quot;&gt;&lt;/a&gt;set(gca,&#39;nextplot&#39;,&#39;replacechildren&#39;);&lt;br /&gt;&lt;a name=&quot;451308&quot;&gt;&lt;/a&gt;for j = 1:20&lt;br /&gt;&lt;a name=&quot;468210&quot;&gt;&lt;/a&gt;    surf(sin(2*pi*j/20)*Z,Z)&lt;br /&gt;&lt;a name=&quot;468212&quot;&gt;&lt;/a&gt;    F(j) = getframe;&lt;br /&gt;&lt;a name=&quot;352256&quot;&gt;&lt;/a&gt;end&lt;br /&gt;&lt;a name=&quot;352257&quot;&gt;&lt;/a&gt;movie(F,20) % Play the movie twenty times&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;376005&quot;&gt; &lt;!-- FNAME:get (timer) --&gt;&lt;/a&gt;&lt;a name=&quot;376005&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;376006&quot;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/6981058572983741274/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/get-timer-display-or-get-timer-object.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/6981058572983741274'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/6981058572983741274'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/get-timer-display-or-get-timer-object.html' title=''/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-3772168511478296898</id><published>2009-08-13T10:42:00.000-07:00</published><updated>2009-08-13T10:45:18.264-07:00</updated><title type='text'></title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;517463&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;get&lt;/span&gt;   &lt;!-- FNAME:get --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;517463&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;517464&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;a name=&quot;362463&quot;&gt;&lt;/a&gt;Get object properties&lt;/p&gt; &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;362464&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;362466&quot;&gt;&lt;/a&gt;get(h)&lt;br /&gt;&lt;a name=&quot;405765&quot;&gt;&lt;/a&gt;get(h,&#39;&lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt;&#39;)&lt;br /&gt;&lt;a name=&quot;558947&quot;&gt;&lt;/a&gt;&lt;m-by-n&gt; = get(H,&lt;property&gt;)&lt;br /&gt;&lt;a name=&quot;541951&quot;&gt;&lt;/a&gt;a = get(h)&lt;br /&gt;&lt;a name=&quot;541606&quot;&gt;&lt;/a&gt;a = get(0,&#39;Factory&#39;)&lt;br /&gt;&lt;a name=&quot;547470&quot;&gt;&lt;/a&gt;a = get(0,&#39;Factory&lt;em&gt;ObjectTypePropertyName&lt;/em&gt;&#39;)&lt;br /&gt;&lt;a name=&quot;391395&quot;&gt;&lt;/a&gt;a = get(h,&#39;Default&#39;)&lt;br /&gt;&lt;a name=&quot;363934&quot;&gt;&lt;/a&gt;a = get(h,&#39;&lt;code&gt;&lt;em&gt;DefaultObjectTypePropertyName&lt;/em&gt;&lt;/code&gt;&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;362467&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;362470&quot;&gt;&lt;/a&gt;&lt;code&gt;get(h) &lt;/code&gt; &lt;a name=&quot;486558&quot;&gt;&lt;/a&gt;returns all properties and their current values of the graphics object identified by the handle &lt;code&gt;h&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;385043&quot;&gt;&lt;/a&gt;&lt;code&gt;get(h,&#39;&lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt;&#39;) &lt;/code&gt; &lt;a name=&quot;486594&quot;&gt;&lt;/a&gt;returns the value of the property &lt;code&gt;&#39;&lt;/code&gt;&lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt;&lt;code&gt;&#39;&lt;/code&gt; of the graphics object identified by &lt;code&gt;h&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;546123&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;m-by-n&gt; = get(H,pn) &lt;/code&gt; &lt;a name=&quot;546269&quot;&gt;&lt;/a&gt;returns &lt;em&gt;n&lt;/em&gt; property values for &lt;em&gt;m&lt;/em&gt; graphics objects in the &lt;em&gt;m&lt;/em&gt;-by-&lt;em&gt;n&lt;/em&gt; cell array, where &lt;code&gt;m = length(H)&lt;/code&gt; and &lt;em&gt;n&lt;/em&gt; is equal to the number of property names contained in &lt;code&gt;pn&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;559076&quot;&gt;&lt;/a&gt;&lt;code&gt;a = get(h) &lt;/code&gt; &lt;a name=&quot;559077&quot;&gt;&lt;/a&gt;returns a structure whose field names are the object&#39;s property names and whose values are the current values of the corresponding properties. &lt;code&gt;h&lt;/code&gt; must be a scalar. If you do not specify an output argument, MATLAB displays the information on the screen.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;546184&quot;&gt;&lt;/a&gt;&lt;code&gt;a = get(0,&#39;Factory&#39;) &lt;/code&gt; &lt;a name=&quot;547515&quot;&gt;&lt;/a&gt;returns the factory-defined values of all user-settable properties. &lt;code&gt;a&lt;/code&gt; is a structure array whose field names are the object property names and whose field values are the values of the corresponding properties. If you do not specify an output argument, MATLAB displays the information on the screen.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;555397&quot;&gt;&lt;/a&gt;&lt;code&gt;a = get(0,&#39;Factory&lt;em&gt;ObjectTypePropertyName&lt;/em&gt;&#39;) &lt;/code&gt; &lt;a name=&quot;555472&quot;&gt;&lt;/a&gt;returns the factory-defined value of the named property for the specified object type. The argument, &lt;code&gt;&lt;em&gt;FactoryObjectTypePropertyName&lt;/em&gt;&lt;/code&gt;, is the word &lt;code&gt;Factory&lt;/code&gt; concatenated with the object type (e.g., &lt;code&gt;Figure&lt;/code&gt;) and the property name (e.g., &lt;code&gt;Color&lt;/code&gt;).&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;678723&quot;&gt;&lt;/a&gt;FactoryFigureColor&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;364165&quot;&gt;&lt;/a&gt;&lt;code&gt;a = get(h,&#39;Default&#39;) &lt;/code&gt; &lt;a name=&quot;486797&quot;&gt;&lt;/a&gt;returns all default values currently defined on object &lt;code&gt;h&lt;/code&gt;. &lt;code&gt;a&lt;/code&gt; is a structure array whose field names are the object property names and whose field values are the values of the corresponding properties. If you do not specify an output argument, MATLAB displays the information on the screen.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;557067&quot;&gt;&lt;/a&gt;&lt;code&gt;a = get(h,&#39;Default&lt;em&gt;ObjectTypePropertyName&lt;/em&gt;&#39;) &lt;/code&gt; &lt;a name=&quot;557068&quot;&gt;&lt;/a&gt;returns the factory-defined value of the named property for the specified object type. The argument, &lt;code&gt;&lt;em&gt;DefaultObjectTypePropertyName&lt;/em&gt;&lt;/code&gt;, is the word &lt;code&gt;Default&lt;/code&gt; concatenated with the object type (e.g., &lt;code&gt;Figure&lt;/code&gt;) and the property name (e.g., &lt;code&gt;Color&lt;/code&gt;).&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;678728&quot;&gt;&lt;/a&gt;DefaultFigureColor&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;391875&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;391895&quot;&gt;&lt;/a&gt;You can obtain the default value of the &lt;code&gt;LineWidth&lt;/code&gt; property for line graphics objects defined on the root level with the statement:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;391896&quot;&gt;&lt;/a&gt;&lt;code&gt;get(0,&#39;DefaultLineLineWidth&#39;)&lt;br /&gt;&lt;/code&gt;&lt;a name=&quot;455207&quot;&gt;&lt;/a&gt;ans =&lt;br /&gt;&lt;a name=&quot;392035&quot;&gt;&lt;/a&gt;     0.5000&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;455001&quot;&gt;&lt;/a&gt;To query a set of properties on all axes children define a cell array of property names:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;558117&quot;&gt;&lt;/a&gt;props = {&#39;HandleVisibility&#39;, &#39;Interruptible&#39;;&lt;br /&gt;&lt;a name=&quot;558170&quot;&gt;&lt;/a&gt;        &#39;SelectionHighlight&#39;, &#39;Type&#39;};&lt;br /&gt;&lt;a name=&quot;558195&quot;&gt;&lt;/a&gt;output = get(get(gca,&#39;Children&#39;),props);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;558216&quot;&gt;&lt;/a&gt;The variable &lt;code&gt;output&lt;/code&gt; is a cell array of dimension&lt;br /&gt;&lt;code&gt;length(get(gca,&#39;Children&#39;)&lt;/code&gt;-by-4.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;558325&quot;&gt;&lt;/a&gt;For example, type&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;558336&quot;&gt;&lt;/a&gt;patch;surface;text;line&lt;br /&gt;&lt;a name=&quot;558357&quot;&gt;&lt;/a&gt;output = get(get(gca,&#39;Children&#39;),props)&lt;br /&gt;&lt;a name=&quot;558382&quot;&gt;&lt;/a&gt;output =&lt;br /&gt;&lt;a name=&quot;558395&quot;&gt;&lt;/a&gt;    &#39;on&#39;    &#39;on&#39;    &#39;on&#39;    &#39;line&#39;&lt;br /&gt;&lt;a name=&quot;558396&quot;&gt;&lt;/a&gt;    &#39;on&#39;    &#39;off&#39;   &#39;on&#39;    &#39;text&#39;&lt;br /&gt;&lt;a name=&quot;558397&quot;&gt;&lt;/a&gt;    &#39;on&#39;    &#39;on&#39;    &#39;on&#39;    &#39;surface&#39;&lt;br /&gt;&lt;a name=&quot;558398&quot;&gt;&lt;/a&gt;    &#39;on&#39;    &#39;on&#39;    &#39;on&#39;    &#39;patch&#39;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;36990&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;get (COM)&lt;/span&gt;   &lt;!-- FNAME:get (COM) --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;36990&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;36991&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Retrieve a property value from an interface or get a list of properties &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;36993&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;70701&quot;&gt;&lt;/a&gt;v = get(h[, &#39;propertyname&#39;])&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;arguments&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;36995&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Arguments&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;36996&quot;&gt;&lt;/a&gt;&lt;code&gt;h &lt;/code&gt;&lt;br /&gt;   &lt;a name=&quot;46752&quot;&gt;&lt;/a&gt;Handle for a COM object previously returned from &lt;code&gt;actxcontrol&lt;/code&gt;, &lt;code&gt;actxserver&lt;/code&gt;, &lt;code&gt;get&lt;/code&gt;, or &lt;code&gt;invoke&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;46753&quot;&gt;&lt;/a&gt;propertyname &lt;br /&gt;   &lt;a name=&quot;36999&quot;&gt;&lt;/a&gt;A string that is the name of the property value to be retrieved.&lt;/p&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;37002&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;37003&quot;&gt;&lt;/a&gt;Returns the value of the property specified by &lt;code&gt;propertyname&lt;/code&gt;. If no property is specified, then &lt;code&gt;get&lt;/code&gt; returns a list of all properties for the object or interface.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;132971&quot;&gt;&lt;/a&gt;The meaning and type of the return value is dependent upon the specific property being retrieved. The object&#39;s documentation should describe the specific meaning of the return value. &lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;60148&quot;&gt;&lt;/a&gt;Create a COM server running Microsoft Excel:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;59699&quot;&gt;&lt;/a&gt;e = actxserver (&#39;Excel.Application&#39;);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;59682&quot;&gt;&lt;/a&gt;Retrieve a single property value:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;72159&quot;&gt;&lt;/a&gt;get(e, &#39;Path&#39;)&lt;br /&gt;&lt;a name=&quot;59718&quot;&gt;&lt;/a&gt;ans =&lt;br /&gt;&lt;a name=&quot;59660&quot;&gt;&lt;/a&gt;   D:\Applications\MSOffice\Office&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;59688&quot;&gt;&lt;/a&gt;Retrieve a list of all properties for the &lt;code&gt;CommandBars&lt;/code&gt; interface:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;72171&quot;&gt;&lt;/a&gt;c = get(e, &#39;CommandBars&#39;);&lt;br /&gt;&lt;a name=&quot;72178&quot;&gt;&lt;/a&gt;get(c)&lt;br /&gt;&lt;a name=&quot;59665&quot;&gt;&lt;/a&gt;ans =&lt;br /&gt;&lt;a name=&quot;72180&quot;&gt;&lt;/a&gt;              Application: [1x1&lt;br /&gt;Interface.excel.application.CommandBars.Application]&lt;br /&gt;&lt;a name=&quot;72181&quot;&gt;&lt;/a&gt;                  Creator: 1.4808e+009&lt;br /&gt;&lt;a name=&quot;72182&quot;&gt;&lt;/a&gt;            ActionControl: []&lt;br /&gt;&lt;a name=&quot;72183&quot;&gt;&lt;/a&gt;            ActiveMenuBar: [1x1&lt;br /&gt;Interface.excel.application.CommandBars.ActiveMenuBar]&lt;br /&gt;&lt;a name=&quot;72184&quot;&gt;&lt;/a&gt;                    Count: 94&lt;br /&gt;&lt;a name=&quot;72185&quot;&gt;&lt;/a&gt;          DisplayTooltips: 1&lt;br /&gt;&lt;a name=&quot;72186&quot;&gt;&lt;/a&gt;    DisplayKeysInTooltips: 0&lt;br /&gt;&lt;a name=&quot;72187&quot;&gt;&lt;/a&gt;             LargeButtons: 0&lt;br /&gt;&lt;a name=&quot;72188&quot;&gt;&lt;/a&gt;       MenuAnimationStyle: &#39;msoMenuAnimationNone&#39;&lt;br /&gt;&lt;a name=&quot;72189&quot;&gt;&lt;/a&gt;                   Parent: [1x1&lt;br /&gt;Interface.excel.application.CommandBars.Parent]&lt;br /&gt;&lt;a name=&quot;72190&quot;&gt;&lt;/a&gt;            AdaptiveMenus: 0&lt;br /&gt;&lt;a name=&quot;59667&quot;&gt;&lt;/a&gt;             DisplayFonts: 1&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;376005&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;get (serial)&lt;/span&gt;   &lt;!-- FNAME:get (serial) --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;376005&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;376006&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Return serial port object properties &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;376008&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;376009&quot;&gt;&lt;/a&gt;get(obj)&lt;br /&gt;&lt;a name=&quot;431107&quot;&gt;&lt;/a&gt;out = get(obj)&lt;br /&gt;&lt;a name=&quot;386009&quot;&gt;&lt;/a&gt;out = get(obj,&#39;&lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt;&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;arguments&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;385969&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Arguments&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;385983&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;2&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;385972&quot;&gt;&lt;/a&gt;&lt;code&gt;obj&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;385974&quot;&gt;&lt;/a&gt;A serial port object or an array of serial port objects.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;385976&quot;&gt;&lt;/a&gt;&lt;code&gt;&#39;&lt;/code&gt;&lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt;&lt;code&gt;&#39;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;385978&quot;&gt;&lt;/a&gt;A &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/ch_ser13.html#serial_props_from_get&quot;&gt;property name&lt;/a&gt; or a cell array of property names.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;385980&quot;&gt;&lt;/a&gt;&lt;code&gt;out&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;385982&quot;&gt;&lt;/a&gt;A single property value, a structure of property values, or a cell array of property values.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;376010&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;431166&quot;&gt;&lt;/a&gt;&lt;code&gt;get(obj) &lt;/code&gt; &lt;a name=&quot;431164&quot;&gt;&lt;/a&gt;returns all property names and their current values to the command line for &lt;code&gt;obj&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;431153&quot;&gt;&lt;/a&gt;&lt;code&gt;out = get(obj) &lt;/code&gt; &lt;a name=&quot;431154&quot;&gt;&lt;/a&gt;returns the structure &lt;code&gt;out&lt;/code&gt; where each field name is the name of a property of &lt;code&gt;obj&lt;/code&gt;, and each field contains the value of that property.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;386561&quot;&gt;&lt;/a&gt;&lt;code&gt;out = get(obj,&#39;&lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt;&#39;) &lt;/code&gt; &lt;a name=&quot;388044&quot;&gt;&lt;/a&gt;returns the value &lt;code&gt;out&lt;/code&gt; of the property specified by &lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt; for &lt;code&gt;obj&lt;/code&gt;. If &lt;code&gt;&lt;em&gt;PropertyName&lt;/em&gt;&lt;/code&gt; is replaced by a 1-by-n or n-by-1 cell array of strings containing property names, then &lt;code&gt;get&lt;/code&gt; returns a 1-by-n cell array of values to &lt;code&gt;out&lt;/code&gt;. If &lt;code&gt;obj&lt;/code&gt; is an array of serial port objects, then &lt;code&gt;out&lt;/code&gt; will be a m-by-n cell array of property values where m is equal to the length of &lt;code&gt;obj&lt;/code&gt; and n is equal to the number of properties specified.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;389007&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;455444&quot;&gt;&lt;/a&gt;Refer to &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/ch_ser13.html#displaying_property_names&quot;&gt;Displaying Property Names and Property Values&lt;/a&gt; for a list of serial port object properties that you can return with &lt;code&gt;get&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;493322&quot;&gt;&lt;/a&gt;When you specify a property name, you can do so without regard to case, and you can make use of property name completion. For example, if &lt;code&gt;s&lt;/code&gt; is a serial port object, then these commands are all valid.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;422348&quot;&gt;&lt;/a&gt;out = get(s,&#39;BaudRate&#39;);&lt;br /&gt;&lt;a name=&quot;422349&quot;&gt;&lt;/a&gt;out = get(s,&#39;baudrate&#39;);&lt;br /&gt;&lt;a name=&quot;422364&quot;&gt;&lt;/a&gt;out = get(s,&#39;BAUD&#39;);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;422344&quot;&gt;&lt;/a&gt;If you use the &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/help.html&quot;&gt;help&lt;/a&gt;&lt;/code&gt; command to display help for &lt;code&gt;get&lt;/code&gt;, then you need to supply the pathname shown below.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;385528&quot;&gt;&lt;/a&gt;help serial/get&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;example&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;376011&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;387500&quot;&gt;&lt;/a&gt;This example illustrates some of the ways you can use &lt;code&gt;get&lt;/code&gt; to return property values for the serial port object &lt;code&gt;s&lt;/code&gt;.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;387517&quot;&gt;&lt;/a&gt;s = serial(&#39;COM1&#39;);&lt;br /&gt;&lt;a name=&quot;387501&quot;&gt;&lt;/a&gt;out1 = get(s);&lt;br /&gt;&lt;a name=&quot;387502&quot;&gt;&lt;/a&gt;out2 = get(s,{&#39;BaudRate&#39;,&#39;DataBits&#39;});&lt;br /&gt;&lt;a name=&quot;387537&quot;&gt;&lt;/a&gt;get(s,&#39;Parity&#39;)&lt;br /&gt;&lt;a name=&quot;507967&quot;&gt;&lt;/a&gt;ans =&lt;br /&gt;&lt;a name=&quot;507969&quot;&gt;&lt;/a&gt;none&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/3772168511478296898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/get-get-object-properties-syntax-geth.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/3772168511478296898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/3772168511478296898'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/get-get-object-properties-syntax-geth.html' title=''/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-6865345917774014029</id><published>2009-08-13T10:41:00.000-07:00</published><updated>2009-08-13T10:42:38.617-07:00</updated><title type='text'></title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;466533&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;genpath&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Generate a path string &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;466536&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;468683&quot;&gt;&lt;/a&gt;genpath&lt;br /&gt;&lt;a name=&quot;500718&quot;&gt;&lt;/a&gt;genpath directory&lt;br /&gt;&lt;a name=&quot;500722&quot;&gt;&lt;/a&gt;p = genpath(&#39;directory&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;466539&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;468719&quot;&gt;&lt;/a&gt;&lt;code&gt;genpath &lt;/code&gt; &lt;a name=&quot;468720&quot;&gt;&lt;/a&gt; returns a path string formed by recursively adding all the directories below &lt;code&gt;matlabroot/toolbox&lt;/code&gt;. Empty directories are not included.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;500726&quot;&gt;&lt;/a&gt;&lt;code&gt;genpath directory &lt;/code&gt; &lt;a name=&quot;500763&quot;&gt;&lt;/a&gt; returns a path string formed by recursively adding all the directories below &lt;code&gt;directory&lt;/code&gt;. Empty directories are not included.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;500782&quot;&gt;&lt;/a&gt;&lt;code&gt;p = genpath(&#39;directory&#39;) &lt;/code&gt; &lt;a name=&quot;500783&quot;&gt;&lt;/a&gt; returns the path string to variable, &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;468766&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;468752&quot;&gt;&lt;/a&gt;You generate a path that includes &lt;code&gt;matlabroot/toolbox/images&lt;/code&gt; and all directories below that with the following command:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;468776&quot;&gt;&lt;/a&gt;&lt;code&gt;p = genpath(fullfile(matlabroot,&#39;toolbox&#39;,&#39;images&#39;))&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;468754&quot;&gt;&lt;/a&gt;&lt;code&gt;p =&lt;/code&gt;&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;468756&quot;&gt;&lt;/a&gt;matlabroot\toolbox\images;matlabroot\toolbox\images\images; &lt;br /&gt;matlabroot\toolbox\images\images\ja;matlabroot\toolbox\images\ &lt;br /&gt;imdemos;matlabroot\toolbox\images\imdemos\ja;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;587837&quot;&gt;&lt;/a&gt;You can also use &lt;code&gt;genpath&lt;/code&gt; in conjunction with &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/addpath.html&quot;&gt;addpath&lt;/a&gt;&lt;/code&gt; to add subdirectories to the path from the command line. The following example adds the &lt;code&gt;/control&lt;/code&gt; directory and its subdirectories to the current path.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;587840&quot;&gt;&lt;/a&gt;%  Display the current path&lt;br /&gt;&lt;a name=&quot;587841&quot;&gt;&lt;/a&gt;path&lt;br /&gt;&lt;a name=&quot;587842&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;588256&quot;&gt;&lt;/a&gt;              MATLABPATH&lt;br /&gt;&lt;a name=&quot;588257&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;587843&quot;&gt;&lt;/a&gt;      K:\toolbox\matlab\general&lt;br /&gt;&lt;a name=&quot;587844&quot;&gt;&lt;/a&gt;      K:\toolbox\matlab\ops&lt;br /&gt;&lt;a name=&quot;587845&quot;&gt;&lt;/a&gt;      K:\toolbox\matlab\lang&lt;br /&gt;&lt;a name=&quot;587846&quot;&gt;&lt;/a&gt;      K:\toolbox\matlab\elmat&lt;br /&gt;&lt;a name=&quot;587847&quot;&gt;&lt;/a&gt;      K:\toolbox\matlab\elfun&lt;br /&gt;&lt;a name=&quot;588226&quot;&gt;&lt;/a&gt;                :&lt;br /&gt;&lt;a name=&quot;588230&quot;&gt;&lt;/a&gt;                :&lt;br /&gt;&lt;a name=&quot;588234&quot;&gt;&lt;/a&gt;                :&lt;br /&gt;&lt;a name=&quot;587853&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;587854&quot;&gt;&lt;/a&gt;%  Use GENPATH to add /control and its subdirectories&lt;br /&gt;&lt;a name=&quot;587855&quot;&gt;&lt;/a&gt;addpath(genpath(&#39;K:/toolbox/control&#39;))&lt;br /&gt;&lt;a name=&quot;587856&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;587857&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;587858&quot;&gt;&lt;/a&gt;%  Display the new path&lt;br /&gt;&lt;a name=&quot;587859&quot;&gt;&lt;/a&gt;path&lt;br /&gt;&lt;a name=&quot;587860&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;588261&quot;&gt;&lt;/a&gt;              MATLABPATH&lt;br /&gt;&lt;a name=&quot;588262&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;587863&quot;&gt;&lt;/a&gt;      K:\toolbox\control&lt;br /&gt;&lt;a name=&quot;587864&quot;&gt;&lt;/a&gt;      K:\toolbox\control\ctrlutil&lt;br /&gt;&lt;a name=&quot;587866&quot;&gt;&lt;/a&gt;      K:\toolbox\control\control&lt;br /&gt;&lt;a name=&quot;587868&quot;&gt;&lt;/a&gt;      K:\toolbox\control\ctrlguis&lt;br /&gt;&lt;a name=&quot;587870&quot;&gt;&lt;/a&gt;      K:\toolbox\control\ctrldemos&lt;br /&gt;&lt;a name=&quot;587872&quot;&gt;&lt;/a&gt;      K:\toolbox\matlab\general&lt;br /&gt;&lt;a name=&quot;587873&quot;&gt;&lt;/a&gt;      K:\toolbox\matlab\ops&lt;br /&gt;&lt;a name=&quot;587874&quot;&gt;&lt;/a&gt;      K:\toolbox\matlab\lang&lt;br /&gt;&lt;a name=&quot;587875&quot;&gt;&lt;/a&gt;      K:\toolbox\matlab\elmat&lt;br /&gt;&lt;a name=&quot;587876&quot;&gt;&lt;/a&gt;      K:\toolbox\matlab\elfun&lt;br /&gt;&lt;a name=&quot;587878&quot;&gt;&lt;/a&gt;                :&lt;br /&gt;&lt;a name=&quot;587879&quot;&gt;&lt;/a&gt;                :&lt;br /&gt;&lt;a name=&quot;587838&quot;&gt;&lt;/a&gt;                :&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;466533&quot;&gt; &lt;!-- FNAME:genpath --&gt;&lt;/a&gt;&lt;a name=&quot;466533&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;466534&quot;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/6865345917774014029/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/genpath-generate-path-string-syntax.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/6865345917774014029'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/6865345917774014029'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/genpath-generate-path-string-syntax.html' title=''/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-7304081246079216203</id><published>2009-08-13T10:37:00.000-07:00</published><updated>2009-08-13T10:41:12.322-07:00</updated><title type='text'></title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;1526&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;gcbf&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Get handle of figure containing object whose callback is executing &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;241&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;242&quot;&gt;&lt;/a&gt;fig = gcbf&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;244&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;245&quot;&gt;&lt;/a&gt;&lt;code&gt;fig = gcbf &lt;/code&gt; &lt;a name=&quot;13723&quot;&gt;&lt;/a&gt;returns the handle of the figure that contains the object whose callback is currently executing. This object can be the figure itself, in which case, &lt;code&gt;gcbf&lt;/code&gt; returns the figure&#39;s handle.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;5734&quot;&gt;&lt;/a&gt;When no callback is executing, &lt;code&gt;gcbf&lt;/code&gt; returns the empty matrix, &lt;code&gt;[]&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;13735&quot;&gt;&lt;/a&gt;The value returned by &lt;code&gt;gcbf&lt;/code&gt; is identical to the &lt;code&gt;figure&lt;/code&gt; output argument returned by &lt;code&gt;gcbo&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;707968&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;gcbo&lt;/span&gt;   &lt;!-- FNAME:gcbo --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;707968&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;707969&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;707971&quot;&gt;&lt;/a&gt;Return the handle of the object whose callback is currently executing&lt;/p&gt; &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;707972&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;707973&quot;&gt;&lt;/a&gt;&lt;code&gt;h = gcbo&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;707974&quot;&gt;&lt;/a&gt;&lt;code&gt;[h, figure] = gcbo&lt;/code&gt;&lt;/p&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;707975&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;707976&quot;&gt;&lt;/a&gt;&lt;code&gt;h = gcbo&lt;/code&gt; returns the handle of the graphics object whose callback is executing.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;707977&quot;&gt;&lt;/a&gt;&lt;code&gt;[h, figure] = gcbo&lt;/code&gt; returns the handle of the current callback object and the handle of the figure containing this object.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;707978&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;707979&quot;&gt;&lt;/a&gt;MATLAB stores the handle of the object whose callback is executing in the root &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/rootobject_props.html#CallbackObject&quot;&gt;&lt;code&gt;CallbackObject&lt;/code&gt;&lt;/a&gt; property. If a callback interrupts another callback, MATLAB replaces the &lt;code&gt;CallbackObject&lt;/code&gt; value with the handle of the object whose callback is interrupting. When that callback completes, MATLAB restores the handle of the object whose callback was interrupted. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;707982&quot;&gt;&lt;/a&gt;The root &lt;code&gt;CallbackObject&lt;/code&gt; property is read-only, so its value is always valid at any time during callback execution. The root &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/rootobject_props.html#CurrentFigure&quot;&gt;&lt;code&gt;CurrentFigure&lt;/code&gt;&lt;/a&gt; property, and the figure &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/figure_props.html#CurrentAxes&quot;&gt;CurrentAxes&lt;/a&gt;&lt;/code&gt; and &lt;code&gt;CurrentObject&lt;/code&gt; properties (returned by &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gcf.html&quot;&gt;gcf&lt;/a&gt;&lt;/code&gt;,&lt;code&gt; &lt;/code&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gca.html&quot;&gt;gca&lt;/a&gt;&lt;/code&gt;, and &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gco.html&quot;&gt;gco&lt;/a&gt;&lt;/code&gt; respectively) are user settable, so they can change during the execution of a callback, especially if that callback is interrupted by another callback. Therefore, those functions are not reliable indicators of which object&#39;s callback is executing.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;707986&quot;&gt;&lt;/a&gt;When you write callback routines for the &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/infotool/hgprop/doc_frame.html&quot;&gt;CreateFcn&lt;/a&gt;&lt;/code&gt; and &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/infotool/hgprop/doc_frame.html&quot;&gt;DeleteFcn&lt;/a&gt;&lt;/code&gt; of any object and the figure &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/figure_props.html#ResizeFcn&quot;&gt;ResizeFcn&lt;/a&gt;&lt;/code&gt;, you must use &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gcbo.html&quot;&gt;gcbo&lt;/a&gt;&lt;/code&gt; since those callbacks do not update the root&#39;s &lt;code&gt;CurrentFigure&lt;/code&gt; property, or the figure&#39;s &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/figure_props.html#CurrentObject&quot;&gt;CurrentObject&lt;/a&gt;&lt;/code&gt; or &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/figure_props.html#CurrentAxes&quot;&gt;CurrentAxes&lt;/a&gt;&lt;/code&gt; properties; they only update the root&#39;s &lt;code&gt;CallbackObject&lt;/code&gt; property.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;707990&quot;&gt;&lt;/a&gt;When no callbacks are executing, &lt;code&gt;gcbo&lt;/code&gt; returns &lt;code&gt;[]&lt;/code&gt; (an empty matrix).&lt;/p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;1526&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;998341&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;gcd&lt;/span&gt;   &lt;!-- FNAME:gcd --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;998341&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;998342&quot;&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;1526&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Greatest common divisor &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;998344&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998345&quot;&gt;&lt;/a&gt;G = gcd(A,B)&lt;br /&gt;&lt;a name=&quot;998346&quot;&gt;&lt;/a&gt;[G,C,D] = gcd(A,B)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;998347&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;998348&quot;&gt;&lt;/a&gt;&lt;code&gt;G = gcd(A,B) &lt;/code&gt; &lt;a name=&quot;998350&quot;&gt;&lt;/a&gt;returns an array containing the greatest common divisors of the corresponding elements of integer arrays &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;B&lt;/code&gt;. By convention, &lt;code&gt;gcd(0,0)&lt;/code&gt; returns a value of &lt;code&gt;0&lt;/code&gt;; all other inputs return positive integers for &lt;code&gt;G&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998351&quot;&gt;&lt;/a&gt;&lt;code&gt;[G,C,D] = gcd(A,B) &lt;/code&gt; &lt;a name=&quot;998352&quot;&gt;&lt;/a&gt;returns both the greatest common divisor array &lt;code&gt;G&lt;/code&gt;, and the arrays &lt;code&gt;C &lt;/code&gt;and &lt;code&gt;D&lt;/code&gt;, which satisfy the equation: &lt;code&gt;A(i).*C(i) + B(i).*D(i) = G(i)&lt;/code&gt;. These are useful for solving Diophantine equations and computing elementary Hermite transformations.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;998355&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;998356&quot;&gt;&lt;/a&gt;The first example involves elementary Hermite transformations. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998357&quot;&gt;&lt;/a&gt;For any two integers &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; there is a &lt;code&gt;2&lt;/code&gt;-by-&lt;code&gt;2&lt;/code&gt; matrix &lt;code&gt;E&lt;/code&gt; with integer entries and determinant = &lt;code&gt;1&lt;/code&gt; (a &lt;em&gt;unimodular&lt;/em&gt; matrix) such that:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998359&quot;&gt;&lt;/a&gt;E * [a;b] = [g,0]&lt;span style=&quot;font-family:sansserif;&quot;&gt;,&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998360&quot;&gt;&lt;/a&gt;where &lt;code&gt;g&lt;/code&gt; is the greatest common divisor of &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; as returned by the command&lt;br /&gt;[g,c,d] = gcd(a,b). &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998361&quot;&gt;&lt;/a&gt;The matrix &lt;code&gt;E&lt;/code&gt; equals:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998362&quot;&gt;&lt;/a&gt;c       d&lt;br /&gt;&lt;a name=&quot;998363&quot;&gt;&lt;/a&gt;-b/g    a/g&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998364&quot;&gt;&lt;/a&gt;In the case where &lt;code&gt;a = 2&lt;/code&gt; and &lt;code&gt;b = 4&lt;/code&gt;:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998365&quot;&gt;&lt;/a&gt;[g,c,d] = gcd(2,4)&lt;br /&gt;&lt;a name=&quot;998366&quot;&gt;&lt;/a&gt;g =&lt;br /&gt;&lt;a name=&quot;998367&quot;&gt;&lt;/a&gt;     2&lt;br /&gt;&lt;a name=&quot;998368&quot;&gt;&lt;/a&gt;c =&lt;br /&gt;&lt;a name=&quot;998369&quot;&gt;&lt;/a&gt;     1&lt;br /&gt;&lt;a name=&quot;998370&quot;&gt;&lt;/a&gt;d =&lt;br /&gt;&lt;a name=&quot;998371&quot;&gt;&lt;/a&gt;     0&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998372&quot;&gt;&lt;/a&gt;So that&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998373&quot;&gt;&lt;/a&gt;E =&lt;br /&gt;&lt;a name=&quot;998374&quot;&gt;&lt;/a&gt;    1     0&lt;br /&gt;&lt;a name=&quot;998375&quot;&gt;&lt;/a&gt;   -2     1&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998376&quot;&gt;&lt;/a&gt;In the next example, we solve for &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; in the Diophantine equation &lt;code&gt;30x + 56y = 8&lt;/code&gt;. &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998377&quot;&gt;&lt;/a&gt;[g,c,d] = gcd(30,56)&lt;br /&gt;&lt;a name=&quot;998378&quot;&gt;&lt;/a&gt;g =&lt;br /&gt;&lt;a name=&quot;998379&quot;&gt;&lt;/a&gt;     2&lt;br /&gt;&lt;a name=&quot;998380&quot;&gt;&lt;/a&gt;c =&lt;br /&gt;&lt;a name=&quot;998381&quot;&gt;&lt;/a&gt;    -13&lt;br /&gt;&lt;a name=&quot;998382&quot;&gt;&lt;/a&gt;d =&lt;br /&gt;&lt;a name=&quot;998383&quot;&gt;&lt;/a&gt;     7&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998384&quot;&gt;&lt;/a&gt;By the definition, for scalars &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;d&lt;/code&gt;: &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998385&quot;&gt;&lt;/a&gt;&lt;code&gt;30(-13) + 56(7) = 2&lt;/code&gt;,&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998386&quot;&gt;&lt;/a&gt;Multiplying through by 8/2: &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998387&quot;&gt;&lt;/a&gt;&lt;code&gt;30(-13&lt;/code&gt;*&lt;code&gt;4) + 56(7&lt;/code&gt;*&lt;code&gt;4) = 8&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998388&quot;&gt;&lt;/a&gt;Comparing this to the original equation, a solution can be read by inspection: &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998389&quot;&gt;&lt;/a&gt;x = (-13*4) = -52; y = (7*4) = 28&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;491530&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;gcf&lt;/span&gt;   &lt;!-- FNAME:gcf --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;491530&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;508365&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;1526&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Get current figure handle &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;148441&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;148442&quot;&gt;&lt;/a&gt;h = gcf&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;148443&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;148444&quot;&gt;&lt;/a&gt;&lt;code&gt;h = gcf &lt;/code&gt; &lt;a name=&quot;623775&quot;&gt;&lt;/a&gt;returns the handle of the current figure. The current figure is the figure window in which graphics commands such as &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/plot.html&quot;&gt;plot&lt;/a&gt;&lt;/code&gt;, &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/title.html&quot;&gt;title&lt;/a&gt;&lt;/code&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;, and &lt;/span&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/surf.html&quot;&gt;surf&lt;/a&gt;&lt;/code&gt; draw their results. If no figure exists, MATLAB creates one and returns its handle. You can use the statement&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;623776&quot;&gt;&lt;/a&gt;get(0,&#39;CurrentFigure&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;623777&quot;&gt;&lt;/a&gt;if you do not want MATLAB to create a figure if one does not already exist.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;338109&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;gco&lt;/span&gt;   &lt;!-- FNAME:gco --&gt;&lt;/a&gt;&lt;a name=&quot;338109&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;491552&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;1526&quot;&gt;&lt;br /&gt;&lt;br /&gt;Return handle of current object &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;11268&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;11269&quot;&gt;&lt;/a&gt;h = gco&lt;br /&gt;&lt;a name=&quot;486541&quot;&gt;&lt;/a&gt;h = gco(figure_handle)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;11270&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;454658&quot;&gt;&lt;/a&gt;&lt;code&gt;h = gco &lt;/code&gt; &lt;a name=&quot;486489&quot;&gt;&lt;/a&gt;returns the handle of the current object.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;454659&quot;&gt;&lt;/a&gt;&lt;code&gt;h = gco(figure_handle) &lt;/code&gt; &lt;a name=&quot;486507&quot;&gt;&lt;/a&gt;returns the value of the current object for the figure specified by &lt;code&gt;figure_handle&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;454542&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;454543&quot;&gt;&lt;/a&gt;The current object is the last object clicked on, excluding &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/uimenu.html&quot;&gt;uimenus&lt;/a&gt;. If the mouse click did not occur over a figure child object, the figure becomes the current object. MATLAB stores the handle of the current object in the figure&#39;s &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/figure_props.html#CurrentObject&quot;&gt;&lt;code&gt;CurrentObject&lt;/code&gt;&lt;/a&gt; property.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;668716&quot;&gt;&lt;/a&gt;The &lt;code&gt;CurrentObject&lt;/code&gt; of the &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/rootobject_props.html#CurrentFigure&quot;&gt;CurrentFigure&lt;/a&gt;&lt;/code&gt; does not always indicate the object whose callback is being executed. Interruptions of callbacks by other callbacks can change the &lt;code&gt;CurrentObject&lt;/code&gt; or even the &lt;code&gt;CurrentFigure&lt;/code&gt;. Some callbacks, such as &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/infotool/hgprop/doc_frame.html&quot;&gt;CreateFcn&lt;/a&gt; and &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/infotool/hgprop/doc_frame.html&quot;&gt;DeleteFcn&lt;/a&gt;, and uimenu &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/uimenu_props.html#Callback&quot;&gt;Callback&lt;/a&gt; intentionally do not update CurrentFigure or CurrentObject. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;673640&quot;&gt;&lt;/a&gt;gcbo provides the only completely reliable way to retrieve the handle to the object whose callback is executing, at any point in the callback function, regardless of the type of callback or of any previous interruptions.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;11271&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;11272&quot;&gt;&lt;/a&gt;This statement returns the handle to the current object in figure window 2:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;282008&quot;&gt;&lt;/a&gt;h = gco(2)&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;1526&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- FNAME:gcbf --&gt;&lt;/a&gt;&lt;a name=&quot;1526&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;1306&quot;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/7304081246079216203/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/gcbf-get-handle-of-figure-containing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/7304081246079216203'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/7304081246079216203'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/gcbf-get-handle-of-figure-containing.html' title=''/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-730316357971215849</id><published>2009-08-13T10:35:00.000-07:00</published><updated>2009-08-13T10:36:47.352-07:00</updated><title type='text'>axes</title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;661817&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;gca&lt;/span&gt;   &lt;!-- FNAME:gca --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;661817&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;491151&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;a name=&quot;149044&quot;&gt;&lt;/a&gt;Get current axes handle&lt;/p&gt; &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;149045&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;149046&quot;&gt;&lt;/a&gt;h = gca&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;149047&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;149048&quot;&gt;&lt;/a&gt;&lt;code&gt;h = gca &lt;/code&gt; &lt;a name=&quot;486467&quot;&gt;&lt;/a&gt;returns the handle to the current axes for the current figure. If no axes exists, MATLAB creates one and returns its handle. You can use the statement&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;623276&quot;&gt;&lt;/a&gt;get(gcf,&#39;CurrentAxes&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;623295&quot;&gt;&lt;/a&gt;if you do not want MATLAB to create an axes if one does not already exist. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;615431&quot;&gt;&lt;/a&gt;The current axes is the target for graphics output when you create axes children. Graphics commands such as &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/plot.html&quot;&gt;plot&lt;/a&gt;&lt;/code&gt;, &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/text.html&quot;&gt;text&lt;/a&gt;&lt;/code&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;, and &lt;/span&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/surf.html&quot;&gt;surf&lt;/a&gt;&lt;/code&gt; draw their results in the current axes. Changing the current figure also changes the current axes.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/730316357971215849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/axes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/730316357971215849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/730316357971215849'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/axes.html' title='axes'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-7179108717353731880</id><published>2009-08-13T10:33:00.000-07:00</published><updated>2009-08-13T10:34:18.963-07:00</updated><title type='text'>gama function</title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999536&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;gamma, gammainc, gammaln&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Gamma functions &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;998308&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998309&quot;&gt;&lt;/a&gt;Y = gamma(A)                &lt;span style=&quot;font-family:sansserif;&quot;&gt;Gamma function&lt;br /&gt;&lt;/span&gt;&lt;a name=&quot;998310&quot;&gt;&lt;/a&gt;Y = gammainc(X,A)           &lt;span style=&quot;font-family:sansserif;&quot;&gt;Incomplete gamma function&lt;br /&gt;&lt;/span&gt;&lt;a name=&quot;998311&quot;&gt;&lt;/a&gt;Y = gammaln(A)              &lt;span style=&quot;font-family:sansserif;&quot;&gt;Logarithm of gamma function&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;definition&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;998312&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Definition&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;998314&quot;&gt;&lt;/a&gt;The gamma function is defined by the integral:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;a name=&quot;998318&quot;&gt;&lt;/a&gt;&lt;li class=&quot;continued&quot;&gt;&lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_ga.gif&quot; align=&quot;bottom&quot; /&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998319&quot;&gt;&lt;/a&gt;The gamma function interpolates the factorial function. For integer &lt;code&gt;n&lt;/code&gt;:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;998320&quot;&gt;&lt;/a&gt;gamma(n+1) = n! = prod(1:n)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;998322&quot;&gt;&lt;/a&gt;The incomplete gamma function is:&lt;/p&gt; &lt;ul&gt;&lt;a name=&quot;998326&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g2a.gif&quot; align=&quot;bottom&quot; /&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;998327&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;998328&quot;&gt;&lt;/a&gt;&lt;code&gt;Y = gamma(A) &lt;/code&gt; &lt;a name=&quot;998329&quot;&gt;&lt;/a&gt;returns the gamma function at the elements of &lt;code&gt;A&lt;/code&gt;. &lt;code&gt;A&lt;/code&gt; must be real.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998330&quot;&gt;&lt;/a&gt;&lt;code&gt;Y = gammainc(X,A) &lt;/code&gt; &lt;a name=&quot;998331&quot;&gt;&lt;/a&gt;returns the incomplete gamma function of corresponding elements of &lt;code&gt;X&lt;/code&gt; and &lt;code&gt;A&lt;/code&gt;. Arguments &lt;code&gt;X&lt;/code&gt; and &lt;code&gt;A&lt;/code&gt; must be real and the same size (or either can be scalar).&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;998332&quot;&gt;&lt;/a&gt;&lt;code&gt;Y = gammaln(A) &lt;/code&gt; &lt;a name=&quot;998334&quot;&gt;&lt;/a&gt;returns the logarithm of the &lt;span style=&quot;font-family:sansserif;&quot;&gt;gamma fun&lt;/span&gt;ction, &lt;code&gt;gammaln(A) = log(gamma(A))&lt;/code&gt;. The &lt;code&gt;gammaln&lt;/code&gt; command avoids the underflow and overflow that may occur if it is computed directly using &lt;code&gt;log(gamma(A))&lt;/code&gt;.&lt;/p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999536&quot;&gt;&lt;br /&gt; &lt;!-- FNAME:gamma, gammainc, gammaln --&gt;&lt;/a&gt;&lt;a name=&quot;999536&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;998306&quot;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/7179108717353731880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/gama-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/7179108717353731880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/7179108717353731880'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/gama-function.html' title='gama function'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-6500375639304009950</id><published>2009-08-13T10:29:00.000-07:00</published><updated>2009-08-13T10:32:29.877-07:00</updated><title type='text'>matrices</title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999647&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;gallery&lt;/span&gt;   &lt;!-- FNAME:gallery --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999647&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999648&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;a name=&quot;999649&quot;&gt;&lt;/a&gt;Test matrices&lt;/p&gt; &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999650&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999651&quot;&gt;&lt;/a&gt;[A,B,C,...] = gallery(&#39;tmfun&#39;,P1,P2,...)&lt;br /&gt;&lt;a name=&quot;999652&quot;&gt;&lt;/a&gt;gallery(3) &lt;span style=&quot;font-family:sansserif;&quot;&gt;a badly conditioned 3-by-3 matrix&lt;br /&gt;&lt;/span&gt;&lt;a name=&quot;999653&quot;&gt;&lt;/a&gt;gallery(5) &lt;span style=&quot;font-family:sansserif;&quot;&gt;an interesting eigenvalue problem&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999654&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999655&quot;&gt;&lt;/a&gt;&lt;code&gt;[A,B,C,...] = gallery(&#39;tmfun&#39;,P1,P2,...) &lt;/code&gt; &lt;a name=&quot;999657&quot;&gt;&lt;/a&gt;returns the test matrices specified by string &lt;code&gt;tmfun&lt;/code&gt;. &lt;code&gt;tmfun&lt;/code&gt; is the name of a matrix family selected from the table below. &lt;code&gt;P1, P2,... &lt;/code&gt;are input parameters required by the individual matrix family. The number of optional parameters &lt;code&gt;P1,P2,...&lt;/code&gt; used in the calling syntax varies from matrix to matrix.The exact calling syntaxes are detailed in the individual matrix descriptions below. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999658&quot;&gt;&lt;/a&gt;The gallery holds over fifty different test matrix functions useful for testing algorithms and other purposes.&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;2&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td colspan=&quot;4&quot; rowspan=&quot;1&quot;&gt;&lt;a name=&quot;999664&quot;&gt;&lt;/a&gt;&lt;b&gt;Test Matrices  &lt;/b&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999673&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999845&quot;&gt;cauchy&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999676&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999852&quot;&gt;chebspec&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999679&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999859&quot;&gt;chebvand&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999682&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999872&quot;&gt;chow&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999685&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999880&quot;&gt;circul&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999688&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999887&quot;&gt;clement&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999691&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999892&quot;&gt;compar&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999694&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999898&quot;&gt;condex&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999697&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999929&quot;&gt;cycol&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999700&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999936&quot;&gt;dorr&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999703&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999942&quot;&gt;dramadah&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999706&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999960&quot;&gt;fiedler&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999709&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999966&quot;&gt;forsythe&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999712&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999972&quot;&gt;frank&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999715&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999976&quot;&gt;gearmat&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999718&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999982&quot;&gt;grcar&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999721&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999986&quot;&gt;hanowa&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999724&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#999993&quot;&gt;house&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999727&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000000&quot;&gt;invhess&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999730&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000006&quot;&gt;invol&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999733&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000011&quot;&gt;ipjfact&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999736&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000016&quot;&gt;jordbloc&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999739&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000020&quot;&gt;kahan&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999742&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000026&quot;&gt;kms&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999745&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000035&quot;&gt;krylov&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999748&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000043&quot;&gt;lauchli&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999751&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000049&quot;&gt;lehmer&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999754&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1007394&quot;&gt;leslie&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999757&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000057&quot;&gt;lesp&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007376&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000062&quot;&gt;lotkin&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007379&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000066&quot;&gt;minij&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007382&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000074&quot;&gt;moler&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999769&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000079&quot;&gt;neumann&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007360&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000083&quot;&gt;orthog&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007363&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000116&quot;&gt;parter&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007366&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000121&quot;&gt;pei&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999781&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000125&quot;&gt;poisson&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007344&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000129&quot;&gt;prolate&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007347&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000136&quot;&gt;randcolu&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007350&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000151&quot;&gt;randcorr&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999793&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000171&quot;&gt;rando&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007328&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000164&quot;&gt;randhess&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007331&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000189&quot;&gt;randsvd&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007334&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000221&quot;&gt;redheff&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999805&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000232&quot;&gt;riemann&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007312&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000243&quot;&gt;ris&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007998&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1011391&quot;&gt;rosser&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1007318&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000265&quot;&gt;smoke&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1008012&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000272&quot;&gt;toeppd&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1011362&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000284&quot;&gt;tridiag&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1011365&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000294&quot;&gt;triw&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1011368&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000303&quot;&gt;vander&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999829&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000307&quot;&gt;wathen&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999831&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/gallery.html#1000317&quot;&gt;wilk&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999833&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999835&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;    &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;a name=&quot;cauchy--cauchy_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999845&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;cauchy--Cauchy matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999846&quot;&gt;&lt;/a&gt;&lt;code&gt;C = gallery(&#39;cauchy&#39;,x,y) &lt;/code&gt; &lt;a name=&quot;999847&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix, &lt;code&gt;C(i,j) = 1/(x(i)+y(j))&lt;/code&gt;. Arguments &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; are vectors of length &lt;code&gt;n&lt;/code&gt;. If you pass in scalars for &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;, they are interpreted as vectors &lt;code&gt;1:x&lt;/code&gt; and &lt;code&gt;1:y&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999848&quot;&gt;&lt;/a&gt;&lt;code&gt;C = gallery(&#39;cauchy&#39;,x) &lt;/code&gt; &lt;a name=&quot;999849&quot;&gt;&lt;/a&gt;returns the same as above with &lt;code&gt;y = x&lt;/code&gt;. That is, the command returns &lt;code&gt;C(i,j) = 1/(x(i)+x(j))&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999850&quot;&gt;&lt;/a&gt;Explicit formulas are known for the inverse and determinant of a Cauchy matrix. The determinant &lt;code&gt;det(C)&lt;/code&gt; is nonzero if &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; both have distinct elements. &lt;code&gt;C&lt;/code&gt; is totally positive if &lt;code&gt;0 &lt;&gt; and &lt;code&gt;0 &lt;&gt;.&lt;/p&gt; &lt;a name=&quot;chebspec--chebyshev_spectral_differentiation_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999852&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;chebspec--Chebyshev spectral differentiation matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999853&quot;&gt;&lt;/a&gt;&lt;code&gt;C = gallery(&#39;chebspec&#39;,n,switch) &lt;/code&gt; &lt;a name=&quot;999854&quot;&gt;&lt;/a&gt;returns a Chebyshev spectral differentiation matrix of order &lt;code&gt;n&lt;/code&gt;. Argument &lt;code&gt;switch&lt;/code&gt; is a variable that determines the character of the output matrix. By default, &lt;code&gt;switch&lt;/code&gt; = &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999855&quot;&gt;&lt;/a&gt;For &lt;code&gt;switch&lt;/code&gt; =&lt;code&gt; 0&lt;/code&gt; (&quot;no boundary conditions&quot;), &lt;code&gt;C&lt;/code&gt; is nilpotent (&lt;code&gt;C^n = 0)&lt;/code&gt; and has the null vector &lt;code&gt;ones(n,1)&lt;/code&gt;. The matrix &lt;code&gt;C&lt;/code&gt; is similar to a Jordan block of size &lt;code&gt;n&lt;/code&gt; with eigenvalue zero.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999856&quot;&gt;&lt;/a&gt;For &lt;code&gt;switch&lt;/code&gt; = &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;C&lt;/code&gt; is nonsingular and well-conditioned, and its eigenvalues have negative real parts.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999857&quot;&gt;&lt;/a&gt;The eigenvector matrix of the Chebyshev spectral differentiation matrix is ill-conditioned. &lt;/p&gt; &lt;a name=&quot;chebvand--vandermonde-like_matrix_for_the_chebyshev_polynomials&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999859&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;chebvand--Vandermonde-like matrix for the Chebyshev polynomials&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999860&quot;&gt;&lt;/a&gt;&lt;code&gt;C = gallery(&#39;chebvand&#39;,p) &lt;/code&gt; &lt;a name=&quot;999861&quot;&gt;&lt;/a&gt;produces the (primal) Chebyshev Vandermonde matrix based on the vector of points &lt;code&gt;p&lt;/code&gt;, which define where the Chebyshev polynomial is calculated.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999862&quot;&gt;&lt;/a&gt;&lt;code&gt;C = gallery(&#39;chebvand&#39;,m,p) &lt;/code&gt; &lt;a name=&quot;999863&quot;&gt;&lt;/a&gt;where &lt;code&gt;m&lt;/code&gt; is scalar, produces a rectangular version of the above, with &lt;code&gt;m&lt;/code&gt; rows. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999870&quot;&gt;&lt;/a&gt;If &lt;code&gt;p&lt;/code&gt; is a vector, then &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g26.gif&quot; align=&quot;bottom&quot; /&gt; where &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g27.gif&quot; align=&quot;bottom&quot; /&gt; is the Chebyshev polynomial of degree &lt;em&gt;i&lt;/em&gt;-1. If &lt;code&gt;p&lt;/code&gt; is a scalar, then &lt;code&gt;p&lt;/code&gt; equally spaced points on the interval &lt;code&gt;[0,1]&lt;/code&gt; are used to calculate &lt;code&gt;C&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;chow--singular_toeplitz_lower_hessenberg_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999872&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;chow--Singular Toeplitz lower Hessenberg matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999873&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;chow&#39;,n,alpha,delta) &lt;/code&gt; &lt;a name=&quot;999874&quot;&gt;&lt;/a&gt;returns &lt;code&gt;A&lt;/code&gt; such that &lt;code&gt;A = H(alpha) + delta*eye(n)&lt;/code&gt;, where &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g28.gif&quot; align=&quot;bottom&quot; /&gt; and argument &lt;code&gt;n&lt;/code&gt; is the order of the Chow matrix. Default value for scalars &lt;code&gt;alpha&lt;/code&gt; and &lt;code&gt;delta&lt;/code&gt; are &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt;, respectively.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999878&quot;&gt;&lt;/a&gt;&lt;code&gt;H(alpha)&lt;/code&gt; has &lt;code&gt;p = floor(n/2)&lt;/code&gt; eigenvalues that are equal to zero. The rest of the eigenvalues are equal to &lt;code&gt;4*alpha*cos(k*pi/(n+2))^2, k=1:n-p&lt;/code&gt;. &lt;/p&gt; &lt;a name=&quot;circul--circulant_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999880&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;circul--Circulant matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999881&quot;&gt;&lt;/a&gt;&lt;code&gt;C = gallery(&#39;circul&#39;,v) &lt;/code&gt; &lt;a name=&quot;999882&quot;&gt;&lt;/a&gt;returns the circulant matrix whose first row is the vector &lt;code&gt;v&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999883&quot;&gt;&lt;/a&gt;A circulant matrix has the property that each row is obtained from the previous one by cyclically permuting the entries one step forward. It is a special Toeplitz matrix in which the diagonals &quot;wrap around.&quot; &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999884&quot;&gt;&lt;/a&gt;If &lt;code&gt;v&lt;/code&gt; is a scalar, then &lt;code&gt;C = gallery(&#39;circul&#39;,1:v)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999885&quot;&gt;&lt;/a&gt;The eigensystem of &lt;code&gt;C&lt;/code&gt; (&lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt;) is known explicitly: If &lt;code&gt;t&lt;/code&gt; is an &lt;code&gt;n&lt;/code&gt;th root of unity, then the inner product of &lt;code&gt;v&lt;/code&gt; and &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g32.gif&quot; align=&quot;bottom&quot; /&gt; is an eigenvalue of &lt;code&gt;C &lt;/code&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;and&lt;/span&gt;&lt;code&gt; w(n:-1:1)&lt;/code&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt; is an eigenvector.&lt;/span&gt;&lt;/p&gt; &lt;a name=&quot;clement--tridiagonal_matrix_with_zero_diagonal_entries&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999887&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;clement--Tridiagonal matrix with zero diagonal entries&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999888&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;clement&#39;,n,sym) &lt;/code&gt; &lt;a name=&quot;999889&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; tridiagonal matrix with zeros on its main diagonal and known eigenvalues. It is singular if order &lt;code&gt;n&lt;/code&gt; is odd. About 64 percent of the entries of the inverse are zero. The eigenvalues include plus and minus the numbers &lt;code&gt;n-1&lt;/code&gt;, &lt;code&gt;n-3&lt;/code&gt;, &lt;code&gt;n-5&lt;/code&gt;, &lt;code&gt;...&lt;/code&gt;, as well as (for odd &lt;code&gt;n&lt;/code&gt;) a final eigenvalue of &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999890&quot;&gt;&lt;/a&gt;Argument &lt;code&gt;sym&lt;/code&gt; determines whether the Clement matrix is symmetric. For &lt;code&gt;sym = 0&lt;/code&gt; (the default) the matrix is nonsymmetric, while for &lt;code&gt;sym = 1&lt;/code&gt;, it is symmetric.&lt;/p&gt; &lt;a name=&quot;compar--comparison_matrices&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999892&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;compar--Comparison matrices&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999893&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;compar&#39;,A,1) &lt;/code&gt; &lt;a name=&quot;999894&quot;&gt;&lt;/a&gt;returns &lt;code&gt;A&lt;/code&gt; with each diagonal element replaced by its absolute value, and each off-diagonal element replaced by minus the absolute value of the largest element in absolute value in its row. However, if &lt;code&gt;A&lt;/code&gt; is triangular &lt;code&gt;compar(A,1)&lt;/code&gt; is too.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999895&quot;&gt;&lt;/a&gt;&lt;code&gt;gallery(&#39;compar&#39;,A)&lt;/code&gt; is &lt;code&gt;diag(B) - tril(B,-1) - triu(B,1)&lt;/code&gt;, where &lt;code&gt;B = abs(A)&lt;/code&gt;. &lt;code&gt;compar(A)&lt;/code&gt; is often denoted by M(&lt;em&gt;A&lt;/em&gt;) in the literature.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999896&quot;&gt;&lt;/a&gt;&lt;code&gt;gallery(&#39;compar&#39;,A,0)&lt;/code&gt; is the same as &lt;code&gt;gallery(&#39;compar&#39;,A)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;condex--counter-examples_to_matrix_condition_number_estimators&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999898&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;condex--Counter-examples to matrix condition number estimators&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999899&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;condex&#39;,n,k,theta) &lt;/code&gt; &lt;a name=&quot;999900&quot;&gt;&lt;/a&gt;returns a &quot;counter-example&quot; matrix to a condition estimator. It has order &lt;code&gt;n&lt;/code&gt; and scalar parameter &lt;code&gt;theta&lt;/code&gt; (default 100).&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999901&quot;&gt;&lt;/a&gt;The matrix, its natural size, and the estimator to which it applies are specified by &lt;code&gt;k&lt;/code&gt;:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1001232&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999904&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 1&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999906&quot;&gt;&lt;/a&gt;   4-by-4&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999908&quot;&gt;&lt;/a&gt;LINPACK&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999910&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 2&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999912&quot;&gt;&lt;/a&gt;   3-by-3&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999914&quot;&gt;&lt;/a&gt;LINPACK&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999916&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 3&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999918&quot;&gt;&lt;/a&gt;   arbitrary&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999920&quot;&gt;&lt;/a&gt;LINPACK (&lt;code&gt;rcond&lt;/code&gt;) (independent of &lt;code&gt;theta&lt;/code&gt;)&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999922&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 4&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999924&quot;&gt;&lt;/a&gt;   &lt;code&gt;n &gt;= 4&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1011592&quot;&gt;&lt;/a&gt;LAPACK (RCOND) (default). It is the inverse of this matrix that is a counter-example.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999927&quot;&gt;&lt;/a&gt;If &lt;code&gt;n&lt;/code&gt; is not equal to the natural size of the matrix, then the matrix is padded out with an identity matrix to order &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;cycol--matrix_whose_columns_repeat_cyclically&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999929&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;cycol--Matrix whose columns repeat cyclically&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999930&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;cycol&#39;,[m n],k) &lt;/code&gt; &lt;a name=&quot;999931&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;m&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix with cyclically repeating columns, where one &quot;cycle&quot; consists of &lt;code&gt;randn(m,k)&lt;/code&gt;. Thus, the rank of matrix &lt;code&gt;A&lt;/code&gt; cannot exceed &lt;code&gt;k&lt;/code&gt;, and &lt;code&gt;k&lt;/code&gt; must be a scalar.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999932&quot;&gt;&lt;/a&gt;Argument &lt;code&gt;k&lt;/code&gt; defaults to &lt;code&gt;round(n/4)&lt;/code&gt;, and need not evenly divide &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999933&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;cycol&#39;,n,k)&lt;span style=&quot;font-family:sansserif;&quot;&gt;, &lt;/span&gt;&lt;/code&gt; &lt;a name=&quot;999934&quot;&gt;&lt;/a&gt;where &lt;code&gt;n&lt;/code&gt; is a scalar, is the same as &lt;code&gt;gallery(&#39;cycol&#39;,[n n],k)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;dorr--diagonally_dominant,_ill-conditioned,_tridiagonal_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999936&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;dorr--Diagonally dominant, ill-conditioned, tridiagonal matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999937&quot;&gt;&lt;/a&gt;&lt;code&gt;[c,d,e] = gallery(&#39;dorr&#39;,n,theta) &lt;/code&gt; &lt;a name=&quot;999938&quot;&gt;&lt;/a&gt;returns the vectors defining an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt;, row diagonally dominant, tridiagonal matrix that is ill-conditioned for small nonnegative values of &lt;code&gt;theta&lt;/code&gt;. The default value of &lt;code&gt;theta&lt;/code&gt; is &lt;code&gt;0.01&lt;/code&gt;. The Dorr matrix itself is the same as &lt;code&gt;gallery(&#39;tridiag&#39;,c,d,e)&lt;/code&gt;. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999939&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;dorr&#39;,n,theta) &lt;/code&gt; &lt;a name=&quot;999940&quot;&gt;&lt;/a&gt;returns the matrix itself, rather than the defining vectors. &lt;/p&gt; &lt;a name=&quot;dramadah--matrix_of_zeros_and_ones_whose_inverse_has_large_integer_entries&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999942&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;dramadah--Matrix of zeros and ones whose inverse has large integer entries&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999943&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;dramadah&#39;,n,k) &lt;/code&gt; &lt;a name=&quot;999944&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix of &lt;code&gt;0&lt;/code&gt;&#39;s and &lt;code&gt;1&lt;/code&gt;&#39;s for which &lt;code&gt;mu(A) = norm(inv(A),&#39;fro&#39;)&lt;/code&gt; is relatively large, although not necessarily maximal. An anti-Hadamard matrix &lt;code&gt;A&lt;/code&gt; is a matrix with elements &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt; for which &lt;code&gt;mu(A)&lt;/code&gt; is maximal.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999945&quot;&gt;&lt;/a&gt;&lt;code&gt;n&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; must both be scalars. Argument &lt;code&gt;k&lt;/code&gt; determines the character of the output matrix:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1001241&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999948&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 1 &lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999950&quot;&gt;&lt;/a&gt;Default. &lt;code&gt;A&lt;/code&gt; is Toeplitz, with &lt;code&gt;abs(det(A)) = 1&lt;/code&gt;, and &lt;code&gt;mu(A) &gt; c(1.75)^n&lt;/code&gt;, where &lt;code&gt;c&lt;/code&gt; is a constant. The inverse of &lt;code&gt;A&lt;/code&gt; has integer entries.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999952&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 2 &lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999954&quot;&gt;&lt;/a&gt;&lt;code&gt;A&lt;/code&gt; is upper triangular and Toeplitz. The inverse of &lt;code&gt;A&lt;/code&gt; has integer entries.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999956&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 3 &lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999958&quot;&gt;&lt;/a&gt;&lt;code&gt;A&lt;/code&gt; has maximal determinant among lower Hessenberg (0,1) matrices. &lt;code&gt;det(A)&lt;/code&gt; = the &lt;code&gt;n&lt;/code&gt;th Fibonacci number. &lt;code&gt;A&lt;/code&gt; is Toeplitz. The eigenvalues have an interesting distribution in the complex plane.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;a name=&quot;fiedler--symmetric_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999960&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;fiedler--Symmetric matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999961&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;fiedler&#39;,c)&lt;span style=&quot;font-family:sansserif;&quot;&gt;, &lt;/span&gt;&lt;/code&gt; &lt;a name=&quot;999962&quot;&gt;&lt;/a&gt;where &lt;code&gt;c&lt;/code&gt; is a length &lt;code&gt;n&lt;/code&gt; vector, returns the &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; symmetric matrix with elements &lt;code&gt;abs(n(i)-n(j))&lt;/code&gt;. For scalar &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;A = gallery(&#39;fiedler&#39;,1:c)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999963&quot;&gt;&lt;/a&gt;Matrix &lt;code&gt;A&lt;/code&gt; has a dominant positive eigenvalue and all the other eigenvalues are negative.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999964&quot;&gt;&lt;/a&gt;Explicit formulas for &lt;code&gt;inv(A)&lt;/code&gt; and &lt;code&gt;det(A)&lt;/code&gt; are given in [Todd, J., &lt;em&gt;Basic Numerical Mathematics&lt;/em&gt;, Vol. 2: Numerical Algebra, Birkhauser, Basel, and Academic Press, New York, 1977, p. 159] and attributed to Fiedler. These indicate that &lt;code&gt;inv(A)&lt;/code&gt; is tridiagonal except for nonzero &lt;code&gt;(1,n)&lt;/code&gt; and &lt;code&gt;(n,1)&lt;/code&gt; elements.&lt;/p&gt; &lt;a name=&quot;forsythe--perturbed_jordan_block&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999966&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;forsythe--Perturbed Jordan block&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999967&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;forsythe&#39;,n,alpha,lambda) &lt;/code&gt; &lt;a name=&quot;999968&quot;&gt;&lt;/a&gt;returns the &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix equal to the Jordan block with eigenvalue &lt;code&gt;lambda&lt;/code&gt;, excepting that &lt;code&gt;A(n,1) = alpha&lt;/code&gt;. The default values of scalars &lt;code&gt;alpha&lt;/code&gt; and &lt;code&gt;lambda&lt;/code&gt; are &lt;code&gt;sqrt(eps)&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt;, respectively.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999969&quot;&gt;&lt;/a&gt;The characteristic polynomial of &lt;code&gt;A&lt;/code&gt; is given by:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999970&quot;&gt;&lt;/a&gt;det(A-t*I) = (lambda-t)^N - alpha*(-1)^n.&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;frank--matrix_with_ill-conditioned_eigenvalues&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999972&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;frank--Matrix with ill-conditioned eigenvalues&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999973&quot;&gt;&lt;/a&gt;&lt;code&gt;F = gallery(&#39;frank&#39;,n,k) &lt;/code&gt; &lt;a name=&quot;999974&quot;&gt;&lt;/a&gt;returns the Frank matrix of order &lt;code&gt;n&lt;/code&gt;. It is upper Hessenberg with determinant &lt;code&gt;1&lt;/code&gt;. If &lt;code&gt;k = 1&lt;/code&gt;, the elements are reflected about the anti-diagonal &lt;code&gt;(1,n)&lt;/code&gt;--&lt;code&gt;(n,1)&lt;/code&gt;. The eigenvalues of &lt;code&gt;F&lt;/code&gt; may be obtained in terms of the zeros of the Hermite polynomials. They are positive and occur in reciprocal pairs; thus if &lt;code&gt;n&lt;/code&gt; is odd, &lt;code&gt;1&lt;/code&gt; is an eigenvalue. &lt;code&gt;F&lt;/code&gt; has &lt;code&gt;floor(n/2)&lt;/code&gt; ill-conditioned eigenvalues--the smaller ones.&lt;/p&gt; &lt;a name=&quot;gearmat--gear_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999976&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;gearmat--Gear matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999977&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;gearmat&#39;,n,i,j) &lt;/code&gt; &lt;a name=&quot;999978&quot;&gt;&lt;/a&gt;returns the &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix with ones on the sub- and super-diagonals, &lt;code&gt;sign(i)&lt;/code&gt; in the &lt;code&gt;(1,abs(i))&lt;/code&gt; position, &lt;code&gt;sign(j)&lt;/code&gt; in the &lt;code&gt;(n,n+1-abs(j))&lt;/code&gt; position, and zeros everywhere else. Arguments &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;j&lt;/code&gt; default to &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;-n&lt;/code&gt;, respectively.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999979&quot;&gt;&lt;/a&gt;Matrix &lt;code&gt;A&lt;/code&gt; is singular, can have double and triple eigenvalues, and can be defective.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999980&quot;&gt;&lt;/a&gt;All eigenvalues are of the form &lt;code&gt;2*cos(a)&lt;/code&gt; and the eigenvectors are of the form &lt;code&gt;[sin(w+a), sin(w+2*a), ..., sin(w+n*a)]&lt;/code&gt;, where &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;w&lt;/code&gt; are given in Gear, C. W., &quot;A Simple Set of Test Matrices for Eigenvalue Programs&quot;, &lt;em&gt;Math. Comp&lt;/em&gt;., Vol. 23 (1969), pp. 119-125.&lt;/p&gt; &lt;a name=&quot;grcar--toeplitz_matrix_with_sensitive_eigenvalues&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999982&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;grcar--Toeplitz matrix with sensitive eigenvalues&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999983&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;grcar&#39;,n,k) &lt;/code&gt; &lt;a name=&quot;999984&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; Toeplitz matrix with &lt;code&gt;-1&lt;/code&gt;s on the subdiagonal, &lt;code&gt;1&lt;/code&gt;s on the diagonal, and &lt;code&gt;k&lt;/code&gt; superdiagonals of &lt;code&gt;1&lt;/code&gt;s. The default is &lt;code&gt;k = 3&lt;/code&gt;. The eigenvalues are sensitive.&lt;/p&gt; &lt;a name=&quot;hanowa--matrix_whose_eigenvalues_lie_on_a_vertical_line_in_the_complex_plane&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999986&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;hanowa--Matrix whose eigenvalues lie on a vertical line in the complex plane&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999987&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;hanowa&#39;,n,d) &lt;/code&gt; &lt;a name=&quot;999988&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; block &lt;code&gt;2&lt;/code&gt;-by-&lt;code&gt;2&lt;/code&gt; matrix of the form:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999989&quot;&gt;&lt;/a&gt;[d*eye(m)   -diag(1:m)&lt;br /&gt;&lt;a name=&quot;999990&quot;&gt;&lt;/a&gt;diag(1:m)   d*eye(m)]&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999991&quot;&gt;&lt;/a&gt;Argument &lt;code&gt;n&lt;/code&gt; is an even integer &lt;code&gt;n=2*m&lt;/code&gt;. Matrix &lt;code&gt;A&lt;/code&gt; has complex eigenvalues of the form &lt;code&gt;d &lt;/code&gt;± &lt;code&gt;k*i&lt;/code&gt;, for &lt;code&gt;1 &lt;= k &lt;= m&lt;/code&gt;. The default value of &lt;code&gt;d&lt;/code&gt; is &lt;code&gt;-1&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;house--householder_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;999993&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;house--Householder matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1008081&quot;&gt;&lt;/a&gt;&lt;code&gt;[v,beta,s] = gallery(&#39;house&#39;,x,k) &lt;/code&gt; &lt;a name=&quot;1008082&quot;&gt;&lt;/a&gt;takes &lt;code&gt;x&lt;/code&gt;, an &lt;code&gt;n&lt;/code&gt;-element column vector, and returns &lt;code&gt;V&lt;/code&gt; and &lt;code&gt;beta&lt;/code&gt; such that &lt;code&gt;H*x = s*e1&lt;/code&gt;. In this expression, &lt;code&gt;e1&lt;/code&gt; is the first column of &lt;code&gt;eye(n)&lt;/code&gt;, &lt;code&gt;abs(s) = norm(x)&lt;/code&gt;, and &lt;code&gt;H = eye(n) - beta*V*V&#39;&lt;/code&gt; is a Householder matrix.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1008120&quot;&gt;&lt;/a&gt;&lt;code&gt;k&lt;/code&gt; determines the sign of &lt;code&gt;s&lt;/code&gt;:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1011553&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1008129&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 0&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1008131&quot;&gt;&lt;/a&gt;&lt;code&gt;sign(s) = -sign(x(1))&lt;/code&gt; (default)&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1008140&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 1&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1008142&quot;&gt;&lt;/a&gt;&lt;code&gt;sign(s) = sign(x(1))&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1008133&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 2&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1008135&quot;&gt;&lt;/a&gt;&lt;code&gt;sign(s) = 1&lt;/code&gt; (&lt;code&gt;x&lt;/code&gt; must be real)&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1008158&quot;&gt;&lt;/a&gt;If &lt;code&gt;x&lt;/code&gt; is complex, then &lt;code&gt;sign(x) = x./abs(x)&lt;/code&gt; when &lt;code&gt;x&lt;/code&gt; is nonzero. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1008079&quot;&gt;&lt;/a&gt;If &lt;code&gt;x = 0&lt;/code&gt;, or if &lt;code&gt;x = alpha*e1&lt;/code&gt; (&lt;code&gt;alpha &gt;= 0&lt;/code&gt;) and either &lt;code&gt;k = 1&lt;/code&gt; or &lt;code&gt;k = 2&lt;/code&gt;, then &lt;code&gt;V = 0&lt;/code&gt;, &lt;code&gt;beta = 1&lt;/code&gt;, and &lt;code&gt;s = x(1)&lt;/code&gt;.  In this case, &lt;code&gt;H&lt;/code&gt; is the identity matrix, which is not strictly a Householder matrix.&lt;/p&gt; &lt;a name=&quot;invhess--inverse_of_an_upper_hessenberg_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000000&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;invhess--Inverse of an upper Hessenberg matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000001&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;invhess&#39;,x,y)&lt;span style=&quot;font-family:sansserif;&quot;&gt;, &lt;/span&gt;&lt;/code&gt; &lt;a name=&quot;1000002&quot;&gt;&lt;/a&gt;where &lt;code&gt;x&lt;/code&gt; is a length &lt;code&gt;n&lt;/code&gt; vector and &lt;code&gt;y&lt;/code&gt; is a length &lt;code&gt;n-1&lt;/code&gt; vector, returns the matrix whose lower triangle agrees with that of &lt;code&gt;ones(n,1)*x&#39;&lt;/code&gt; and whose strict upper triangle agrees with that of &lt;code&gt;[1 y]*ones(1,n)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000003&quot;&gt;&lt;/a&gt;The matrix is nonsingular if &lt;code&gt;x(1) ~= 0&lt;/code&gt; and &lt;code&gt;x(i+1) ~= y(i)&lt;/code&gt; for all &lt;code&gt;i&lt;/code&gt;, and its inverse is an upper Hessenberg matrix. Argument &lt;code&gt;y&lt;/code&gt; defaults to &lt;code&gt;-x(1:n-1)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000004&quot;&gt;&lt;/a&gt;If &lt;code&gt;x&lt;/code&gt; is a scalar, &lt;code&gt;invhess(x)&lt;/code&gt; is the same as &lt;code&gt;invhess(1:x)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;invol--involutory_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000006&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;invol--Involutory matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000007&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;invol&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000008&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; involutory &lt;code&gt;(A*A = eye(n))&lt;/code&gt; and ill-conditioned matrix. It is a diagonally scaled version of &lt;code&gt;hilb(n)&lt;/code&gt;. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000009&quot;&gt;&lt;/a&gt;&lt;code&gt;B = (eye(n)-A)/2&lt;/code&gt; and &lt;code&gt;B = (eye(n)+A)/2&lt;/code&gt; are idempotent &lt;code&gt;(B*B = B)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;ipjfact--hankel_matrix_with_factorial_elements&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000011&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;ipjfact--Hankel matrix with factorial elements&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000012&quot;&gt;&lt;/a&gt;&lt;code&gt;[A,d] = gallery(&#39;ipjfact&#39;,n,k) &lt;/code&gt; &lt;a name=&quot;1000013&quot;&gt;&lt;/a&gt;returns &lt;code&gt;A&lt;/code&gt;, an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; Hankel matrix, and &lt;code&gt;d&lt;/code&gt;, the determinant of &lt;code&gt;A&lt;/code&gt;, which is known explicitly. If &lt;code&gt;k = 0&lt;/code&gt; (the default), then the elements of &lt;code&gt;A&lt;/code&gt; are &lt;code&gt;A(i,j) = (i+j)!&lt;/code&gt;   If &lt;code&gt;k = 1&lt;/code&gt;, then the elements of &lt;code&gt;A&lt;/code&gt; are &lt;code&gt;A(i,j) = 1/(i+j)&lt;/code&gt;. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000014&quot;&gt;&lt;/a&gt;Note that the inverse of &lt;code&gt;A&lt;/code&gt; is also known explicitly.&lt;/p&gt; &lt;a name=&quot;jordbloc--jordan_block&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000016&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;jordbloc--Jordan block&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000017&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;jordbloc&#39;,n,lambda) &lt;/code&gt; &lt;a name=&quot;1000018&quot;&gt;&lt;/a&gt;returns the &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; Jordan block with eigenvalue &lt;code&gt;lambda&lt;/code&gt;. The default value for &lt;code&gt;lambda&lt;/code&gt; is &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;kahan--upper_trapezoidal_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000020&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;kahan--Upper trapezoidal matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000021&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;kahan&#39;,n,theta,pert) &lt;/code&gt; &lt;a name=&quot;1000022&quot;&gt;&lt;/a&gt;returns an upper trapezoidal matrix that has interesting properties regarding estimation of condition and rank.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000023&quot;&gt;&lt;/a&gt;If &lt;code&gt;n&lt;/code&gt; is a two-element vector, then &lt;code&gt;A&lt;/code&gt; is &lt;code&gt;n(1)&lt;/code&gt;-by-&lt;code&gt;n(2)&lt;/code&gt;; otherwise, &lt;code&gt;A&lt;/code&gt; is &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt;. The useful range of &lt;code&gt;theta&lt;/code&gt; is &lt;code&gt;0 &lt;&gt;, with a default value of &lt;code&gt;1.2&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000024&quot;&gt;&lt;/a&gt;To ensure that the QR factorization with column pivoting does not interchange columns in the presence of rounding errors, the diagonal is perturbed by &lt;code&gt;pert*eps*diag([n:-1:1])&lt;/code&gt;. The default &lt;code&gt;pert&lt;/code&gt; is &lt;code&gt;25&lt;/code&gt;, which ensures no interchanges for &lt;code&gt;gallery(&#39;kahan&#39;,n)&lt;/code&gt; up to at least &lt;code&gt;n = 90&lt;/code&gt; in IEEE arithmetic.&lt;/p&gt; &lt;a name=&quot;kms--kac-murdock-szego_toeplitz_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000026&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;kms--Kac-Murdock-Szego Toeplitz matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000027&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;kms&#39;,n,rho) &lt;/code&gt; &lt;a name=&quot;1000028&quot;&gt;&lt;/a&gt;returns the &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; Kac-Murdock-Szego Toeplitz matrix such that &lt;code&gt;A(i,j) = rho^(abs(i-j))&lt;/code&gt;, for real &lt;code&gt;rho&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000029&quot;&gt;&lt;/a&gt;For complex &lt;code&gt;rho&lt;/code&gt;, the same formula holds except that elements below the diagonal are conjugated. &lt;code&gt;rho&lt;/code&gt; defaults to 0.5.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000030&quot;&gt;&lt;/a&gt;The KMS matrix &lt;code&gt;A&lt;/code&gt; has these properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;1000031&quot;&gt;&lt;/a&gt;An LDL&#39; factorization with &lt;code&gt;L = inv(gallery(&#39;triw&#39;,n,-rho,1))&#39;&lt;/code&gt;, and &lt;code&gt;D(i,i) = (1-abs(rho)^2)*eye(n)&lt;/code&gt;, except &lt;code&gt;D(1,1) = 1&lt;/code&gt;. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000032&quot;&gt;&lt;/a&gt;Positive definite if and only if &lt;code&gt;0 &lt;&gt;.  &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000033&quot;&gt;&lt;/a&gt;The inverse &lt;code&gt;inv(A)&lt;/code&gt; is tridiagonal. &lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;krylov--krylov_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000035&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;krylov--Krylov matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000036&quot;&gt;&lt;/a&gt;&lt;code&gt;B = gallery(&#39;krylov&#39;,A,x,j) &lt;/code&gt; &lt;a name=&quot;1000037&quot;&gt;&lt;/a&gt;returns the Krylov matrix &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1000038&quot;&gt;&lt;/a&gt;&lt;code&gt;[x, Ax, A^2x, ..., A^(j-1)x]&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1000039&quot;&gt;&lt;/a&gt;where &lt;code&gt;A&lt;/code&gt; is an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix and &lt;code&gt;x&lt;/code&gt; is a length &lt;code&gt;n&lt;/code&gt; vector. The defaults are &lt;code&gt;x = ones(n,1)&lt;/code&gt;, and &lt;code&gt;j = n&lt;/code&gt;. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000040&quot;&gt;&lt;/a&gt;&lt;code&gt;B = gallery(&#39;krylov&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000041&quot;&gt;&lt;/a&gt;is the same as &lt;code&gt;gallery(&#39;krylov&#39;,(randn(n))&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;lauchli--rectangular_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000043&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;lauchli--Rectangular matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000044&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;lauchli&#39;,n,mu) &lt;/code&gt; &lt;a name=&quot;1000045&quot;&gt;&lt;/a&gt;returns the &lt;code&gt;(n+1)&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1000046&quot;&gt;&lt;/a&gt;&lt;code&gt;[ones(1,n); mu&lt;/code&gt;*&lt;code&gt;eye(n)]&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1000047&quot;&gt;&lt;/a&gt;The Lauchli matrix is a well-known example in least squares and other problems that indicates the dangers of forming &lt;code&gt;A&#39;*A&lt;/code&gt;. Argument &lt;code&gt;mu&lt;/code&gt; defaults to &lt;code&gt;sqrt(eps)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;lehmer--symmetric_positive_definite_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000049&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;lehmer--Symmetric positive definite matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000050&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;lehmer&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000051&quot;&gt;&lt;/a&gt;returns the symmetric positive definite &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix such that &lt;code&gt;A(i,j) = i/j&lt;/code&gt; for&lt;code&gt; j &gt;= i&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000052&quot;&gt;&lt;/a&gt;The Lehmer matrix &lt;code&gt;A&lt;/code&gt; has these properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;1000053&quot;&gt;&lt;/a&gt;&lt;code&gt;A&lt;/code&gt; is totally nonnegative.  &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000054&quot;&gt;&lt;/a&gt;The inverse &lt;code&gt;inv(A)&lt;/code&gt; is tridiagonal and explicitly known. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000055&quot;&gt;&lt;/a&gt;The order &lt;code&gt;n &lt;= cond(A) &lt;= 4*n*n&lt;/code&gt;. &lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;leslie--&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1007394&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;leslie--&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1008886&quot;&gt;&lt;/a&gt;&lt;code&gt;L = gallery(&#39;leslie&#39;,a,b) &lt;/code&gt; &lt;a name=&quot;1008914&quot;&gt;&lt;/a&gt;is the &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix from the Leslie population model with average birth numbers &lt;code&gt;a(1:n)&lt;/code&gt; and survival rates &lt;code&gt;b(1:n-1)&lt;/code&gt;.  It is zero, apart from the first row (which contains the &lt;code&gt;a(i)&lt;/code&gt;) and the first subdiagonal (which contains the &lt;code&gt;b(i)&lt;/code&gt;).  For a valid model, the &lt;code&gt;a(i)&lt;/code&gt; are nonnegative and the &lt;code&gt;b(i)&lt;/code&gt; are positive and bounded by 1, i.e., &lt;code&gt;0 &lt;&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1008893&quot;&gt;&lt;/a&gt;&lt;code&gt;L = gallery(&#39;leslie&#39;,n) &lt;/code&gt; &lt;a name=&quot;1008915&quot;&gt;&lt;/a&gt;generates the Leslie matrix with &lt;code&gt;a = ones(n,1)&lt;/code&gt;, &lt;code&gt;b = ones(n-1,1)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;lesp--tridiagonal_matrix_with_real,_sensitive_eigenvalues&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000057&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;lesp--Tridiagonal matrix with real, sensitive eigenvalues&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000058&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;lesp&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000059&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix whose eigenvalues are real and smoothly distributed in the interval approximately &lt;code&gt;[-2*N-3.5, -4.5]&lt;/code&gt;. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000060&quot;&gt;&lt;/a&gt;The sensitivities of the eigenvalues increase exponentially as the eigenvalues grow more negative. The matrix is similar to the symmetric tridiagonal matrix with the same diagonal entries and with off-diagonal entries 1, via a similarity transformation with &lt;code&gt;D = diag(1!,2!,...,n!)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;lotkin--lotkin_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000062&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;lotkin--Lotkin matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000063&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;lotkin&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000064&quot;&gt;&lt;/a&gt;returns the Hilbert matrix with its first row altered to all ones. The Lotkin matrix &lt;code&gt;A&lt;/code&gt; is nonsymmetric, ill-conditioned, and has many negative eigenvalues of small magnitude. Its inverse has integer entries and is known explicitly.&lt;/p&gt; &lt;a name=&quot;minij--symmetric_positive_definite_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000066&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;minij--Symmetric positive definite matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000067&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;minij&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000068&quot;&gt;&lt;/a&gt;returns the &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; symmetric positive definite matrix with &lt;code&gt;A(i,j) = min(i,j).&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000069&quot;&gt;&lt;/a&gt;The &lt;code&gt;minij&lt;/code&gt; matrix has these properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;1000070&quot;&gt;&lt;/a&gt;The inverse&lt;code&gt; inv(A)&lt;/code&gt; is tridiagonal and equal to &lt;code&gt;-1&lt;/code&gt; times the second difference matrix, except its &lt;code&gt;(n,n)&lt;/code&gt; element is &lt;code&gt;1&lt;/code&gt;. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000071&quot;&gt;&lt;/a&gt;Givens&#39; matrix, &lt;code&gt;2*A-ones(size(A))&lt;/code&gt;, has tridiagonal inverse and eigenvalues &lt;code&gt;0.5*sec((2*r-1)*pi/(4*n))^2&lt;/code&gt;, where &lt;code&gt;r=1:n&lt;/code&gt;. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000072&quot;&gt;&lt;/a&gt;&lt;code&gt;(n+1)*ones(size(A))-A&lt;/code&gt; has elements that are &lt;code&gt;max(i,j)&lt;/code&gt; and a tridiagonal inverse. &lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;moler--symmetric_positive_definite_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000074&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;moler--Symmetric positive definite matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000075&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;moler&#39;,n,alpha) &lt;/code&gt; &lt;a name=&quot;1000076&quot;&gt;&lt;/a&gt;returns the symmetric positive definite &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix &lt;code&gt;U&#39;*U&lt;/code&gt;, where &lt;code&gt;U = gallery(&#39;triw&#39;,n,alpha)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000077&quot;&gt;&lt;/a&gt;For the default &lt;code&gt;alpha &lt;/code&gt;= &lt;code&gt;-1&lt;/code&gt;, &lt;code&gt;A(i,j) = min(i,j)-2&lt;/code&gt;, and &lt;code&gt;A(i,i) = i&lt;/code&gt;. One of the eigenvalues of &lt;code&gt;A&lt;/code&gt; is small.&lt;/p&gt; &lt;a name=&quot;neumann--singular_matrix_from_the_discrete_neumann_problem_(sparse)&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000079&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;neumann--Singular matrix from the discrete Neumann problem (sparse)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000080&quot;&gt;&lt;/a&gt;&lt;code&gt;C = gallery(&#39;neumann&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000081&quot;&gt;&lt;/a&gt;returns the sparse &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; singular, row diagonally dominant matrix resulting from discretizing the Neumann problem with the usual five-point operator on a regular mesh. Argument &lt;code&gt;n&lt;/code&gt; is a perfect square integer &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g23.gif&quot; align=&quot;bottom&quot; /&gt; or a two-element vector. &lt;code&gt;C&lt;/code&gt; is sparse and has a one-dimensional null space with null vector &lt;code&gt;ones(n,1)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;orthog--orthogonal_and_nearly_orthogonal_matrices&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000083&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;orthog--Orthogonal and nearly orthogonal matrices&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000084&quot;&gt;&lt;/a&gt;&lt;code&gt;Q = gallery(&#39;orthog&#39;,n,k) &lt;/code&gt; &lt;a name=&quot;1000085&quot;&gt;&lt;/a&gt;returns the kth type of matrix of order &lt;code&gt;n&lt;/code&gt;, where &lt;code&gt;k &gt; 0&lt;/code&gt; selects exactly orthogonal matrices, and &lt;code&gt;k &lt;&gt; selects diagonal scalings of orthogonal matrices. Available types are:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1001259&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000088&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 1&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000090&quot;&gt;&lt;/a&gt;&lt;code&gt;Q(i,j) = sqrt(2/(n+1)) * sin(i*j*pi/(n+1))&lt;/code&gt;&lt;br /&gt;&lt;a name=&quot;1001264&quot;&gt;&lt;/a&gt;Symmetric eigenvector matrix for second difference matrix. This is the default.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000092&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 2&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000094&quot;&gt;&lt;/a&gt;&lt;code&gt;Q(i,j) = 2/(sqrt(2*n+1)) * sin(2*i*j*pi/(2*n+1))&lt;/code&gt;&lt;br /&gt;&lt;a name=&quot;1001265&quot;&gt;&lt;/a&gt;Symmetric.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000096&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 3&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000098&quot;&gt;&lt;/a&gt;&lt;code&gt;Q(r,s) = exp(2*pi*i*(r-1)*(s-1)/n) / sqrt(n)&lt;/code&gt;&lt;br /&gt;&lt;a name=&quot;1001266&quot;&gt;&lt;/a&gt;Unitary, the Fourier matrix. Q^4 is the identity. This is essentially the same matrix as &lt;code&gt;fft(eye(n))/sqrt(n)!&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000100&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 4&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000102&quot;&gt;&lt;/a&gt;Helmert matrix: a permutation of a lower Hessenberg matrix, whose first row is &lt;code&gt;ones(1:n)/sqrt(n)&lt;/code&gt;.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000104&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 5&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000106&quot;&gt;&lt;/a&gt;Q(i,j) = &lt;code&gt;sin(2*pi*(i-1)*(j-1)/n) + cos(2*pi*(i-1)*(j-1)/n)&lt;/code&gt;&lt;br /&gt;&lt;a name=&quot;1001267&quot;&gt;&lt;/a&gt;Symmetric matrix arising in the Hartley transform.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1008990&quot;&gt;&lt;/a&gt;&lt;code&gt;K = 6&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1008992&quot;&gt;&lt;/a&gt;Q(i,j) = sqrt(2/n)*cos((i-1/2)*(j-1/2)*pi/n)&lt;br /&gt;&lt;a name=&quot;1009009&quot;&gt;&lt;/a&gt;Symmetric matrix arising as a discrete cosine transform.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000108&quot;&gt;&lt;/a&gt;&lt;code&gt;k = -1&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000110&quot;&gt;&lt;/a&gt;&lt;code&gt;Q(i,j) = cos((i-1)*(j-1)*pi/(n-1))&lt;/code&gt;&lt;br /&gt;&lt;a name=&quot;1001271&quot;&gt;&lt;/a&gt;Chebyshev Vandermonde-like matrix, based on extrema of &lt;code&gt;T(n-1)&lt;/code&gt;.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000112&quot;&gt;&lt;/a&gt;&lt;code&gt;k = -2&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000114&quot;&gt;&lt;/a&gt;&lt;code&gt;Q(i,j) = cos((i-1)*(j-1/2)*pi/n))&lt;/code&gt;&lt;br /&gt;&lt;a name=&quot;1001274&quot;&gt;&lt;/a&gt;Chebyshev Vandermonde-like matrix, based on zeros of &lt;code&gt;T(n)&lt;/code&gt;.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;a name=&quot;parter--toeplitz_matrix_with_singular_values_near_pi&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000116&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;parter--Toeplitz matrix with singular values near pi&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000117&quot;&gt;&lt;/a&gt;&lt;code&gt;C = gallery(&#39;parter&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000118&quot;&gt;&lt;/a&gt;returns the matrix &lt;code&gt;C&lt;/code&gt; such that &lt;code&gt;C(i,j) = 1/(i-j+0.5)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000119&quot;&gt;&lt;/a&gt;&lt;code&gt;C&lt;/code&gt; is a Cauchy matrix and a Toeplitz matrix. Most of the singular values of &lt;code&gt;C&lt;/code&gt; are very close to &lt;code&gt;pi&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;pei--pei_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000121&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;pei--Pei matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000122&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;pei&#39;,n,alpha)&lt;span style=&quot;font-family:sansserif;&quot;&gt;, &lt;/span&gt;&lt;/code&gt; &lt;a name=&quot;1000123&quot;&gt;&lt;/a&gt;where &lt;code&gt;alpha&lt;/code&gt; is a scalar, returns the symmetric matrix &lt;code&gt;alpha*eye(n) + ones(n)&lt;/code&gt;. The default for &lt;code&gt;alpha&lt;/code&gt; is 1. The matrix is singular for &lt;code&gt;alpha&lt;/code&gt; equal to either &lt;code&gt;0&lt;/code&gt; or -&lt;code&gt;n&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;poisson--block_tridiagonal_matrix_from_poissons_equation_(sparse)&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000125&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;poisson--Block tridiagonal matrix from Poisson&#39;s equation (sparse)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000126&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;poisson&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000127&quot;&gt;&lt;/a&gt;returns the block tridiagonal (sparse) matrix of order &lt;code&gt;n^2&lt;/code&gt; resulting from discretizing Poisson&#39;s equation with the 5-point operator on an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; mesh.&lt;/p&gt; &lt;a name=&quot;prolate--symmetric,_ill-conditioned_toeplitz_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000129&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;prolate--Symmetric, ill-conditioned Toeplitz matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000130&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;prolate&#39;,n,w) &lt;/code&gt; &lt;a name=&quot;1000131&quot;&gt;&lt;/a&gt;returns the &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; prolate matrix with parameter &lt;code&gt;w&lt;/code&gt;. It is a symmetric Toeplitz matrix.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000132&quot;&gt;&lt;/a&gt;If &lt;code&gt;0 &lt;&gt; then &lt;code&gt;A&lt;/code&gt; is positive definite&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;1000133&quot;&gt;&lt;/a&gt;The eigenvalues of &lt;code&gt;A&lt;/code&gt; are distinct, lie in &lt;code&gt;(0,1)&lt;/code&gt;, and tend to cluster around &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000134&quot;&gt;&lt;/a&gt;The default value of &lt;code&gt;w&lt;/code&gt; is 0.25. &lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;randcolu_--_random_matrix_with_normalized_cols_and_specified_singular_values&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000136&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;randcolu -- Random matrix with normalized cols and specified singular values&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000137&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;randcolu&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000138&quot;&gt;&lt;/a&gt;is a random &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix with columns of unit 2-norm, with random singular values whose squares are from a uniform distribution.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000139&quot;&gt;&lt;/a&gt;&lt;code&gt;A&#39;*A&lt;/code&gt; is a correlation matrix of the form produced by &lt;code&gt;gallery(&#39;randcorr&#39;,n)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000140&quot;&gt;&lt;/a&gt;&lt;code&gt;gallery(&#39;randcolu&#39;,x) &lt;/code&gt; &lt;a name=&quot;1000141&quot;&gt;&lt;/a&gt;where &lt;code&gt;x&lt;/code&gt; is an &lt;code&gt;n&lt;/code&gt;-vector (&lt;code&gt;n&lt;/code&gt; &gt; 1), produces a random &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix having singular values given by the vector &lt;code&gt;x&lt;/code&gt;. The vector &lt;code&gt;x&lt;/code&gt; must have nonnegative elements whose sum of squares is &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000142&quot;&gt;&lt;/a&gt;&lt;code&gt;gallery(&#39;randcolu&#39;,x,m) &lt;/code&gt; &lt;a name=&quot;1000143&quot;&gt;&lt;/a&gt;where &lt;code&gt;m &gt;= n&lt;/code&gt;, produces an &lt;code&gt;m&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000144&quot;&gt;&lt;/a&gt;&lt;code&gt;gallery(&#39;randcolu&#39;,x,m,k) &lt;/code&gt; &lt;a name=&quot;1000145&quot;&gt;&lt;/a&gt;provides a further option:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1001275&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1001278&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 0&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1001280&quot;&gt;&lt;/a&gt;&lt;code&gt;diag(x)&lt;/code&gt; is initially subjected to a random two-sided orthogonal transformation, and then a sequence of Givens rotations is applied (default).&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1001282&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 1&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1001284&quot;&gt;&lt;/a&gt;The initial transformation is omitted. This is much faster, but the resulting matrix may have zero entries.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000148&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000151&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;randcorr -- Random correlation matrix with specified eigenvalues&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000152&quot;&gt;&lt;/a&gt;&lt;code&gt;gallery(&#39;randcorr&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000153&quot;&gt;&lt;/a&gt;is a random &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; correlation matrix with random eigenvalues from a uniform distribution. A correlation matrix is a symmetric positive semidefinite matrix with &lt;code&gt;1&lt;/code&gt;s on the diagonal&lt;code&gt;&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000154&quot;&gt;&lt;/a&gt;&lt;code&gt;gallery(&#39;randcorr&#39;,x) &lt;/code&gt; &lt;a name=&quot;1000155&quot;&gt;&lt;/a&gt;produces a random correlation matrix having eigenvalues given by the vector &lt;code&gt;x&lt;/code&gt;, where &lt;code&gt;length(x) &gt; 1&lt;/code&gt;. The vector &lt;code&gt;x&lt;/code&gt; must have nonnegative elements summing to &lt;code&gt;length(x)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000156&quot;&gt;&lt;/a&gt;&lt;code&gt;gallery(&#39;randcorr&#39;,x,k) &lt;/code&gt; &lt;a name=&quot;1000157&quot;&gt;&lt;/a&gt;provides a further option:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1001303&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1001314&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 0&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1001308&quot;&gt;&lt;/a&gt;The diagonal matrix of eigenvalues is initially subjected to a random orthogonal similarity transformation, and then a sequence of Givens rotations is applied (default).&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1001316&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 1&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1001312&quot;&gt;&lt;/a&gt;The initial transformation is omitted. This is much faster, but the resulting matrix may have some zero entries.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000160&quot;&gt;&lt;/a&gt;For more information, see: &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000161&quot;&gt;&lt;/a&gt;[1]  Bendel, R. B. and M. R. Mickey, &quot;Population Correlation Matrices for  Sampling Experiments,&quot; &lt;em&gt;Commun. Statist. Simulation Comput.&lt;/em&gt;, B7, 1978,  pp. 163-182. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000162&quot;&gt;&lt;/a&gt;[2]  Davies, P. I. and N. J. Higham, &quot;Numerically Stable Generation of  Correlation Matrices and Their Factors,&quot; &lt;em&gt;BIT&lt;/em&gt;, Vol. 40, 2000, pp. 640-651. &lt;/p&gt; &lt;a name=&quot;randhess--random,_orthogonal_upper_hessenberg_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000164&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;randhess--Random, orthogonal upper Hessenberg matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000165&quot;&gt;&lt;/a&gt;&lt;code&gt;H = gallery(&#39;randhess&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000166&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; real, random, orthogonal upper Hessenberg matrix. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000167&quot;&gt;&lt;/a&gt;&lt;code&gt;H = gallery(&#39;randhess&#39;,x) &lt;/code&gt; &lt;a name=&quot;1000168&quot;&gt;&lt;/a&gt;if &lt;code&gt;x&lt;/code&gt; is an arbitrary, real, length &lt;code&gt;n&lt;/code&gt; vector with &lt;code&gt;n &gt; 1&lt;/code&gt;, constructs &lt;code&gt;H&lt;/code&gt; nonrandomly using the elements of &lt;code&gt;x&lt;/code&gt; as parameters. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000169&quot;&gt;&lt;/a&gt;Matrix &lt;code&gt;H&lt;/code&gt; is constructed via a product of &lt;code&gt;n-1&lt;/code&gt; Givens rotations.&lt;/p&gt; &lt;a name=&quot;rando--random_matrix_composed_of_elements_-1,_0_or_1&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000171&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;rando--Random matrix composed of elements -1, 0 or 1&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000172&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;rando&#39;,n,k) &lt;/code&gt; &lt;a name=&quot;1000173&quot;&gt;&lt;/a&gt;returns a random &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix with elements from one of the following discrete distributions:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1001333&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000176&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 1&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000178&quot;&gt;&lt;/a&gt; &lt;code&gt;A(i,j)&lt;/code&gt; = &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt; with equal probability (default).&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000180&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 2&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000182&quot;&gt;&lt;/a&gt; &lt;code&gt;A(i,j)&lt;/code&gt; = &lt;code&gt;-1&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt; with equal probability.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000184&quot;&gt;&lt;/a&gt;&lt;code&gt;k = 3&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000186&quot;&gt;&lt;/a&gt; &lt;code&gt;A(i,j)&lt;/code&gt; = &lt;code&gt;-1&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt; with equal probability.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000187&quot;&gt;&lt;/a&gt;Argument &lt;code&gt;n&lt;/code&gt; may be a two-element vector, in which case the matrix is &lt;code&gt;n(1)&lt;/code&gt;-by-&lt;code&gt;n(2)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;randsvd--random_matrix_with_preassigned_singular_values&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000189&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;randsvd--Random matrix with preassigned singular values&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000190&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;randsvd&#39;,n,kappa,mode,kl,ku) &lt;/code&gt; &lt;a name=&quot;1000191&quot;&gt;&lt;/a&gt;returns a banded (multidiagonal) random matrix of order &lt;code&gt;n&lt;/code&gt; with &lt;code&gt;cond(A) = kappa&lt;/code&gt; and singular values from the distribution mode. If &lt;code&gt;n&lt;/code&gt; is a two-element vector, &lt;code&gt;A&lt;/code&gt; is &lt;code&gt;n(1)&lt;/code&gt;-by-&lt;code&gt;n(2)&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000192&quot;&gt;&lt;/a&gt;Arguments &lt;code&gt;kl&lt;/code&gt; and &lt;code&gt;ku&lt;/code&gt; specify the number of lower and upper off-diagonals, respectively, in &lt;code&gt;A&lt;/code&gt;. If they are omitted, a full matrix is produced. If only &lt;code&gt;kl&lt;/code&gt; is present, &lt;code&gt;ku&lt;/code&gt; defaults to &lt;code&gt;kl&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000218&quot;&gt;&lt;/a&gt;Distribution &lt;code&gt;mode&lt;/code&gt; can be:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1001346&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000195&quot;&gt;&lt;/a&gt;&lt;code&gt;1&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000197&quot;&gt;&lt;/a&gt; One large singular value.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000199&quot;&gt;&lt;/a&gt;&lt;code&gt;2&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000201&quot;&gt;&lt;/a&gt; One small singular value.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000203&quot;&gt;&lt;/a&gt;&lt;code&gt;3&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000205&quot;&gt;&lt;/a&gt; Geometrically distributed singular values (default).&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000207&quot;&gt;&lt;/a&gt;&lt;code&gt;4&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000209&quot;&gt;&lt;/a&gt; Arithmetically distributed singular values.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000211&quot;&gt;&lt;/a&gt;&lt;code&gt;5&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000213&quot;&gt;&lt;/a&gt; Random singular values with uniformly distributed logarithm.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1000215&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1000217&quot;&gt;&lt;/a&gt;If &lt;code&gt;mode&lt;/code&gt; is &lt;code&gt;-1&lt;/code&gt;,  &lt;code&gt;-2&lt;/code&gt;, &lt;code&gt;-3&lt;/code&gt;, &lt;code&gt;-4&lt;/code&gt;, or &lt;code&gt;-5&lt;/code&gt;, then &lt;code&gt;randsvd&lt;/code&gt; treats &lt;code&gt;mode&lt;/code&gt; as &lt;code&gt;abs(mode)&lt;/code&gt;, except that in the original matrix of singular values the order of the diagonal entries is reversed: small to large instead of large to small.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000219&quot;&gt;&lt;/a&gt;Condition number &lt;code&gt;kappa&lt;/code&gt; defaults to &lt;code&gt;sqrt(1/eps)&lt;/code&gt;. In the special case where &lt;code&gt;kappa &lt;&gt;, &lt;code&gt;A&lt;/code&gt; is a random, full, symmetric, positive definite matrix with &lt;code&gt;cond(A) = -kappa&lt;/code&gt; and eigenvalues distributed according to &lt;code&gt;mode&lt;/code&gt;. Arguments &lt;code&gt;kl&lt;/code&gt; and &lt;code&gt;ku&lt;/code&gt;, if present, are ignored.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1009021&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;randsvd&#39;,n,kappa,mode,kl,ku,method) &lt;/code&gt; &lt;a name=&quot;1009025&quot;&gt;&lt;/a&gt;specifies how the computations are carried out. &lt;code&gt;method = 0&lt;/code&gt; is the default, while &lt;code&gt;method = 1&lt;/code&gt; uses an alternative method that is much faster for large dimensions, even though it uses more flops.&lt;/p&gt; &lt;a name=&quot;redheff--redheffers_matrix_of_1s_and_0s&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000221&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;redheff--Redheffer&#39;s matrix of 1s and 0s&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000222&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;redheff&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000223&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix of &lt;code&gt;0&lt;/code&gt;&#39;s and &lt;code&gt;1&lt;/code&gt;&#39;s defined by &lt;code&gt;A(i,j) = 1&lt;/code&gt;, if &lt;code&gt;j = 1&lt;/code&gt; or if &lt;code&gt;i&lt;/code&gt; divides &lt;code&gt;j&lt;/code&gt;, and &lt;code&gt;A(i,j) = 0&lt;/code&gt; otherwise.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000224&quot;&gt;&lt;/a&gt;The Redheffer matrix has these properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;1000225&quot;&gt;&lt;/a&gt;&lt;code&gt;(n-floor(log2(n)))-1&lt;/code&gt; eigenvalues equal to &lt;code&gt;1&lt;/code&gt;  &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000226&quot;&gt;&lt;/a&gt;A real eigenvalue (the spectral radius) approximately &lt;code&gt;sqrt(n)&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000227&quot;&gt;&lt;/a&gt;A negative eigenvalue approximately &lt;code&gt;-sqrt(n)&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000228&quot;&gt;&lt;/a&gt;The remaining eigenvalues are provably &quot;small.&quot; &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000229&quot;&gt;&lt;/a&gt;The Riemann hypothesis is true if and only if&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g14.gif&quot; align=&quot;bottom&quot; /&gt; for every epsilon &lt;code&gt;&gt; 0&lt;/code&gt;. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1000230&quot;&gt;&lt;/a&gt;Barrett and Jarvis conjecture that &quot;the small eigenvalues all lie inside the unit circle &lt;code&gt;abs(Z) = 1&lt;/code&gt;,&quot; and a proof of this conjecture, together with a proof that some eigenvalue tends to zero as &lt;code&gt;n&lt;/code&gt; tends to infinity, would yield a new proof of the prime number theorem.&lt;/p&gt; &lt;a name=&quot;riemann--matrix_associated_with_the_riemann_hypothesis&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000232&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;riemann--Matrix associated with the Riemann hypothesis&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000233&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;riemann&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000234&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix for which the Riemann hypothesis is true if and only if &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;a name=&quot;1010658&quot;&gt;&lt;/a&gt;&lt;li class=&quot;continued&quot;&gt;&lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g18.gif&quot; align=&quot;bottom&quot; /&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1010661&quot;&gt;&lt;/a&gt; for every &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g33.gif&quot; align=&quot;bottom&quot; /&gt;. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000235&quot;&gt;&lt;/a&gt;The Riemann matrix is defined by:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1000236&quot;&gt;&lt;/a&gt;A = B(2:n+1,2:n+1)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1000237&quot;&gt;&lt;/a&gt;where &lt;code&gt;B(i,j) = i-1&lt;/code&gt; if &lt;code&gt;i&lt;/code&gt; divides &lt;code&gt;j&lt;/code&gt;, and &lt;code&gt;B(i,j) = -1&lt;/code&gt; otherwise.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000238&quot;&gt;&lt;/a&gt;The Riemann matrix has these properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;1000239&quot;&gt;&lt;/a&gt;Each eigenvalue &lt;code&gt;e(i)&lt;/code&gt; satisfies &lt;code&gt;abs(e(i)) &lt;= m-1/m&lt;/code&gt;, where &lt;code&gt;m = n+1&lt;/code&gt;. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000240&quot;&gt;&lt;/a&gt;&lt;code&gt;i &lt;= e(i) &lt;= i+1&lt;/code&gt; with at most &lt;code&gt;m-sqrt(m)&lt;/code&gt; exceptions. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1000241&quot;&gt;&lt;/a&gt;All integers in the interval &lt;code&gt;(m/3, m/2]&lt;/code&gt; are eigenvalues. &lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;ris--symmetric_hankel_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000243&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;ris--Symmetric Hankel matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000244&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;ris&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000245&quot;&gt;&lt;/a&gt;returns a symmetric &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; Hankel matrix with elements &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1000246&quot;&gt;&lt;/a&gt;A(i,j) = 0.5/(n-i-j+1.5)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1000253&quot;&gt;&lt;/a&gt;The eigenvalues of &lt;code&gt;A&lt;/code&gt; cluster around &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g29.gif&quot; align=&quot;bottom&quot; /&gt; and &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_g30.gif&quot; align=&quot;bottom&quot; /&gt;. This matrix was invented by F.N. Ris.&lt;/p&gt; &lt;a name=&quot;rosser--classic_symmetric_eigenvalue_test_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1011391&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;rosser--Classic symmetric eigenvalue test matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1011392&quot;&gt;&lt;/a&gt;&lt;code&gt;A = rosser &lt;/code&gt; &lt;a name=&quot;1011543&quot;&gt;&lt;/a&gt;returns the Rosser matrix. This matrix was a challenge for many matrix eigenvalue algorithms. But the QR algorithm, as perfected by Wilkinson and implemented in MATLAB, has no trouble with it. The matrix is 8-by-8 with integer elements. It has:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;1011520&quot;&gt;&lt;/a&gt;A double eigenvalue &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1011521&quot;&gt;&lt;/a&gt;Three nearly equal eigenvalues &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1011522&quot;&gt;&lt;/a&gt;Dominant eigenvalues of opposite sign &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1011523&quot;&gt;&lt;/a&gt;A zero eigenvalue &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;1011533&quot;&gt;&lt;/a&gt;A small, nonzero eigenvalue &lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;smoke--complex_matrix_with_a_smoke_ring_pseudospectrum&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000265&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;smoke--Complex matrix with a &#39;smoke ring&#39; pseudospectrum&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000266&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;smoke&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000267&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix with &lt;code&gt;1&lt;/code&gt;&#39;s on the superdiagonal, &lt;code&gt;1&lt;/code&gt; in the &lt;code&gt;(n,1)&lt;/code&gt; position, and powers of roots of unity along the diagonal.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000268&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;smoke&#39;,n,1) &lt;/code&gt; &lt;a name=&quot;1000269&quot;&gt;&lt;/a&gt;returns the same except that element &lt;code&gt;A(n,1)&lt;/code&gt; is zero.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000270&quot;&gt;&lt;/a&gt;The eigenvalues of &lt;code&gt;gallery(&#39;smoke&#39;,n,1)&lt;/code&gt; are the &lt;code&gt;n&lt;/code&gt;th roots of unity; those of &lt;code&gt;gallery(&#39;smoke&#39;,n&lt;/code&gt;) are the &lt;code&gt;n&lt;/code&gt;th roots of unity times &lt;code&gt;2^(1/n)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;toeppd--symmetric_positive_definite_toeplitz_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000272&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;toeppd--Symmetric positive definite Toeplitz matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000273&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;toeppd&#39;,n,m,w,theta) &lt;/code&gt; &lt;a name=&quot;1000274&quot;&gt;&lt;/a&gt;returns an &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; symmetric, positive semi-definite (SPD) Toeplitz matrix composed of the sum of &lt;code&gt;m&lt;/code&gt; rank 2 (or, for certain &lt;code&gt;theta&lt;/code&gt;, rank 1) SPD Toeplitz matrices. Specifically,&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1000275&quot;&gt;&lt;/a&gt;T = w(1)&lt;code&gt;*&lt;/code&gt;T(theta(1)) + ... + w(m)&lt;code&gt;*&lt;/code&gt;T(theta(m))&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1000276&quot;&gt;&lt;/a&gt;where &lt;code&gt;T(theta(k))&lt;/code&gt; has &lt;code&gt;(i,j)&lt;/code&gt; element &lt;code&gt;cos(2*pi*theta(k)*(i-j))&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000277&quot;&gt;&lt;/a&gt;By default: &lt;code&gt;m = n&lt;/code&gt;, &lt;code&gt;w = rand(m,1)&lt;/code&gt;, and &lt;code&gt;theta = rand(m,1)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;toeppen--pentadiagonal_toeplitz_matrix_(sparse)&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000279&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;toeppen--Pentadiagonal Toeplitz matrix (sparse)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000280&quot;&gt;&lt;/a&gt;&lt;code&gt;P = gallery(&#39;toeppen&#39;,n,a,b,c,d,e) &lt;/code&gt; &lt;a name=&quot;1000281&quot;&gt;&lt;/a&gt;returns the &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; sparse, pentadiagonal Toeplitz matrix with the diagonals: &lt;code&gt;P(3,1) = a&lt;/code&gt;, &lt;code&gt;P(2,1) = b&lt;/code&gt;, &lt;code&gt;P(1,1) = c&lt;/code&gt;, &lt;code&gt;P(1,2) = d&lt;/code&gt;, and &lt;code&gt;P(1,3) = e&lt;/code&gt;, where &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, and &lt;code&gt;e&lt;/code&gt; are scalars.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000282&quot;&gt;&lt;/a&gt;By default, &lt;code&gt;(a,b,c,d,e)&lt;/code&gt; = &lt;code&gt;(1,-10,0,10,1)&lt;/code&gt;, yielding a matrix of Rutishauser. This matrix has eigenvalues lying approximately on the line segment &lt;code&gt;2*cos(2*t) + 20*i*sin(t)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;tridiag--tridiagonal_matrix_(sparse)&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000284&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;tridiag--Tridiagonal matrix (sparse)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000285&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;tridiag&#39;,c,d,e) &lt;/code&gt; &lt;a name=&quot;1000286&quot;&gt;&lt;/a&gt;returns the tridiagonal matrix with subdiagonal &lt;code&gt;c&lt;/code&gt;, diagonal &lt;code&gt;d&lt;/code&gt;, and superdiagonal &lt;code&gt;e&lt;/code&gt;. Vectors &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;e&lt;/code&gt; must have &lt;code&gt;length(d)-1&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000287&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;tridiag&#39;,n,c,d,e)&lt;span style=&quot;font-family:sansserif;&quot;&gt;, &lt;/span&gt;&lt;/code&gt; &lt;a name=&quot;1000288&quot;&gt;&lt;/a&gt;where &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, and &lt;code&gt;e&lt;/code&gt; are all scalars, yields the Toeplitz tridiagonal matrix of order &lt;code&gt;n&lt;/code&gt; with subdiagonal elements &lt;code&gt;c&lt;/code&gt;, diagonal elements &lt;code&gt;d&lt;/code&gt;, and superdiagonal elements &lt;code&gt;e&lt;/code&gt;.   This matrix has eigenvalues &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1000289&quot;&gt;&lt;/a&gt;d + 2*sqrt(c*e)*cos(k*pi/(n+1))&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1000290&quot;&gt;&lt;/a&gt;where &lt;code&gt;k = 1:n&lt;/code&gt;. (see [1].)&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000291&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;tridiag&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000292&quot;&gt;&lt;/a&gt;is the same as &lt;code&gt;A = gallery(&#39;tridiag&#39;,n,-1,2,-1)&lt;/code&gt;, which is a symmetric positive definite M-matrix (the negative of the second difference matrix).&lt;/p&gt; &lt;a name=&quot;triw--upper_triangular_matrix_discussed_by_wilkinson_and_others&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000294&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;triw--Upper triangular matrix discussed by Wilkinson and others&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000295&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;triw&#39;,n,alpha,k) &lt;/code&gt; &lt;a name=&quot;1000296&quot;&gt;&lt;/a&gt;returns the upper triangular matrix with ones on the diagonal and &lt;code&gt;alpha&lt;/code&gt;s on the first &lt;code&gt;k &gt;= 0&lt;/code&gt; superdiagonals.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000297&quot;&gt;&lt;/a&gt;Order &lt;code&gt;n&lt;/code&gt; may be a 2-element vector, in which case the matrix is &lt;code&gt;n(1)&lt;/code&gt;-by-&lt;code&gt;n(2)&lt;/code&gt; and upper trapezoidal.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000298&quot;&gt;&lt;/a&gt;Ostrowski [&quot;On the Spectrum of a One-parametric Family of Matrices, &lt;em&gt;J. Reine Angew. Math., &lt;/em&gt;1954] shows that&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1000299&quot;&gt;&lt;/a&gt;cond(gallery(&#39;triw&#39;,n,2)) = cot(pi/(4*n))^2,&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1000300&quot;&gt;&lt;/a&gt;and, for large &lt;code&gt;abs(alpha)&lt;/code&gt;, &lt;code&gt;cond(gallery(&#39;triw&#39;,n,alpha))&lt;/code&gt; is approximately &lt;code&gt;abs(alpha)^n*sin(pi/(4*n-2))&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000301&quot;&gt;&lt;/a&gt;Adding &lt;code&gt;-2^(2-n)&lt;/code&gt; to the &lt;code&gt;(n,1)&lt;/code&gt; element makes &lt;code&gt;triw(n)&lt;/code&gt; singular, as does adding&lt;br /&gt;&lt;code&gt;-2^(1-n)&lt;/code&gt; to all the elements in the first column.&lt;/p&gt; &lt;a name=&quot;vander--vandermonde_matrix&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000303&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;vander--Vandermonde matrix&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000304&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;vander&#39;,c)  &lt;/code&gt; &lt;a name=&quot;1000305&quot;&gt;&lt;/a&gt;returns the Vandermonde matrix whose second to last column is &lt;code&gt;c&lt;/code&gt;. The &lt;code&gt;j&lt;/code&gt;th column of a Vandermonde matrix is given by &lt;code&gt;A(:,j) = C^(n-j)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;wathen--finite_element_matrix_(sparse,_random_entries)&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000307&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;wathen--Finite element matrix (sparse, random entries)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000308&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;wathen&#39;,nx,ny) &lt;/code&gt; &lt;a name=&quot;1000309&quot;&gt;&lt;/a&gt;returns a sparse, random, &lt;code&gt;n&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; finite element matrix where &lt;code&gt;n = 3*nx*ny + 2*nx + 2*ny + 1&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000311&quot;&gt;&lt;/a&gt;Matrix &lt;code&gt;A&lt;/code&gt; is precisely the &quot;consistent mass matrix&quot; for a regular &lt;code&gt;nx&lt;/code&gt;-by-&lt;code&gt;ny&lt;/code&gt; grid of 8-node (serendipity) elements in two dimensions. &lt;code&gt;A&lt;/code&gt; is symmetric, positive definite for any (positive) values of the &quot;density,&quot; &lt;code&gt;rho(nx,ny)&lt;/code&gt;, which is chosen randomly in this routine.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1000312&quot;&gt;&lt;/a&gt;&lt;code&gt;A = gallery(&#39;wathen&#39;,nx,ny,1) &lt;/code&gt; &lt;a name=&quot;1000313&quot;&gt;&lt;/a&gt;returns a diagonally scaled matrix such that &lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1000314&quot;&gt;&lt;/a&gt;&lt;code&gt;0.25 &lt;= eig(inv(D)&lt;/code&gt;*&lt;code&gt;A) &lt;= 4.5&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;1000315&quot;&gt;&lt;/a&gt;where &lt;code&gt;D = diag(diag(A))&lt;/code&gt; for any positive integers &lt;code&gt;nx&lt;/code&gt; and &lt;code&gt;ny&lt;/code&gt; and any densities &lt;code&gt;rho(nx,ny)&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;wilk--various_matrices_devised_or_discussed_by_wilkinson&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;1000317&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;wilk--Various matrices devised or discussed by Wilkinson&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;1000318&quot;&gt;&lt;/a&gt;&lt;code&gt;[A,b] = gallery(&#39;wilk&#39;,n) &lt;/code&gt; &lt;a name=&quot;1000319&quot;&gt;&lt;/a&gt;returns a different matrix or linear system depending on the value of &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;1001912&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt;  &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt;&lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1001919&quot;&gt;&lt;/a&gt;&lt;code&gt;n = 3&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1001921&quot;&gt;&lt;/a&gt;Upper triangular system &lt;code&gt;Ux=b&lt;/code&gt; illustrating inaccurate solution.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1001923&quot;&gt;&lt;/a&gt;&lt;code&gt;n = 4&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1001925&quot;&gt;&lt;/a&gt;Lower triangular system &lt;code&gt;Lx=b&lt;/code&gt;, ill-conditioned.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1001927&quot;&gt;&lt;/a&gt;&lt;code&gt;n = 5&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1001929&quot;&gt;&lt;/a&gt;&lt;code&gt;hilb(6)(1:5,2:6)*1.8144&lt;/code&gt;. A symmetric positive definite matrix.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;1001931&quot;&gt;&lt;/a&gt;&lt;code&gt;n = 21&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;1001933&quot;&gt;&lt;/a&gt;&lt;code&gt;W21+&lt;/code&gt;, a tridiagonal matrix.   Eigenvalue problem.&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/6500375639304009950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/matrices.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/6500375639304009950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/6500375639304009950'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/matrices.html' title='matrices'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-8595535402198131685</id><published>2009-08-13T10:27:00.001-07:00</published><updated>2009-08-13T10:28:52.956-07:00</updated><title type='text'>zero function</title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999807&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;fzero&lt;/span&gt;   &lt;!-- FNAME:fzero --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999807&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999808&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;a name=&quot;999810&quot;&gt;&lt;/a&gt;Find zero of a function of one variable&lt;/p&gt; &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999811&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999812&quot;&gt;&lt;/a&gt;x = fzero(fun,x0)&lt;br /&gt;&lt;a name=&quot;999813&quot;&gt;&lt;/a&gt;x = fzero(fun,x0,options)&lt;br /&gt;&lt;a name=&quot;999814&quot;&gt;&lt;/a&gt;x = fzero(fun,x0,options,P1,P2,...)&lt;br /&gt;&lt;a name=&quot;999815&quot;&gt;&lt;/a&gt;[x,fval] = fzero(...)&lt;br /&gt;&lt;a name=&quot;999816&quot;&gt;&lt;/a&gt;[x,fval,exitflag] = fzero(...)&lt;br /&gt;&lt;a name=&quot;999817&quot;&gt;&lt;/a&gt;[x,fval,exitflag,output] = fzero(...)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999818&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999819&quot;&gt;&lt;/a&gt;&lt;code&gt;x = fzero(fun,x0) &lt;/code&gt; &lt;a name=&quot;999821&quot;&gt;&lt;/a&gt;tries to find a zero of &lt;code&gt;fun&lt;/code&gt; near &lt;code&gt;x0&lt;/code&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;, if &lt;/span&gt;&lt;code&gt;x0&lt;/code&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt; is a scalar&lt;/span&gt;. The value &lt;code&gt;x&lt;/code&gt; returned by &lt;code&gt;fzero&lt;/code&gt; is near a point where &lt;code&gt;fun&lt;/code&gt; changes sign, or &lt;code&gt;NaN&lt;/code&gt; if the search fails.&lt;span style=&quot;font-family:sansserif;&quot;&gt; &lt;/span&gt;In this case, the search terminates when the search interval is expanded until an &lt;code&gt;Inf&lt;/code&gt;, &lt;code&gt;NaN&lt;/code&gt;, or complex value is found.&lt;span style=&quot;font-family:sansserif;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999822&quot;&gt;&lt;/a&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;If &lt;/span&gt;&lt;code&gt;x0&lt;/code&gt; is a vector of length two, &lt;code&gt;fzero&lt;/code&gt; assumes &lt;code&gt;x0&lt;/code&gt; is an interval where the sign of &lt;code&gt;fun(x0(1))&lt;/code&gt; differs from the sign of &lt;code&gt;fun(x0(2))&lt;/code&gt;. An error occurs if this is not true. Calling &lt;code&gt;fzero&lt;/code&gt; with such an interval guarantees &lt;code&gt;fzero&lt;/code&gt; will return a value near a point where &lt;code&gt;fun&lt;/code&gt; changes sign.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999823&quot;&gt;&lt;/a&gt;&lt;code&gt;x = fzero(fun,x0,options) &lt;/code&gt; &lt;a name=&quot;999824&quot;&gt;&lt;/a&gt;minimizes with the optimization parameters specified in the structure &lt;code&gt;options&lt;/code&gt;. You can define these parameters using the &lt;code&gt;optimset&lt;/code&gt; function. &lt;code&gt;fzero&lt;/code&gt; uses these &lt;code&gt;options&lt;/code&gt; structure fields:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1012513&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999827&quot;&gt;&lt;/a&gt;&lt;code&gt;Display&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999829&quot;&gt;&lt;/a&gt;Level of display. &lt;code&gt;&#39;off&#39;&lt;/code&gt; displays no output; &lt;code&gt;&#39;iter&#39;&lt;/code&gt; displays output at each iteration; &lt;code&gt;&#39;final&#39;&lt;/code&gt; displays just the final output; &lt;code&gt;&#39;notify&#39;&lt;/code&gt; (default) dislays output only if the function does not converge.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999831&quot;&gt;&lt;/a&gt;&lt;code&gt;TolX&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999833&quot;&gt;&lt;/a&gt;Termination tolerance on &lt;code&gt;x.&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999834&quot;&gt;&lt;/a&gt;&lt;code&gt;x = fzero(fun,x0,options,P1,P2,...) &lt;/code&gt; &lt;a name=&quot;999835&quot;&gt;&lt;/a&gt;provides for additional arguments passed to the function, &lt;code&gt;fun&lt;/code&gt;. Use &lt;code&gt;options = []&lt;/code&gt; as a placeholder if no options are set.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999836&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,fval] = fzero(...) &lt;/code&gt; &lt;a name=&quot;999837&quot;&gt;&lt;/a&gt;returns the value of the objective function &lt;code&gt;fun&lt;/code&gt; at the solution &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999838&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,fval,exitflag] = fzero(...) &lt;/code&gt; &lt;a name=&quot;999839&quot;&gt;&lt;/a&gt;returns a value &lt;code&gt;exitflag&lt;/code&gt; that describes the exit condition of &lt;code&gt;fzero&lt;/code&gt;:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1012514&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999842&quot;&gt;&lt;/a&gt;&lt;code&gt;&gt;0&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999844&quot;&gt;&lt;/a&gt;Indicates that the function found a zero &lt;code&gt;x.&lt;/code&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999846&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;0&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999848&quot;&gt;&lt;/a&gt;No interval was found with a sign change, or a &lt;code&gt;NaN&lt;/code&gt; or &lt;code&gt;Inf&lt;/code&gt; function value was encountered during search for an interval containing a sign change, or a complex function value was encountered during the search for an interval containing a sign change.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999849&quot;&gt;&lt;/a&gt;&lt;code&gt;[x,fval,exitflag,output] = fzero(...) &lt;/code&gt; &lt;a name=&quot;999850&quot;&gt;&lt;/a&gt;returns a structure &lt;code&gt;output&lt;/code&gt; that contains information about the optimization:&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;1012522&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;0&quot; cellpadding=&quot;5&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999853&quot;&gt;&lt;/a&gt;&lt;code&gt;output.algorithm&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999855&quot;&gt;&lt;/a&gt;The algorithm used&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999857&quot;&gt;&lt;/a&gt;&lt;code&gt;output.funcCount&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999859&quot;&gt;&lt;/a&gt;The number of function evaluations&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;999861&quot;&gt;&lt;/a&gt;&lt;code&gt;output.iterations&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;999863&quot;&gt;&lt;/a&gt;The number of iterations taken&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;ul&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr width=&quot;90%&quot;&gt;&lt;td bgcolor=&quot;#ffe4b0&quot;&gt;&lt;a name=&quot;999864&quot;&gt;&lt;/a&gt;&lt;b&gt;Note  &lt;/b&gt;   For the purposes of this command, zeros are considered to be points where the function actually crosses, not just touches, the &lt;em&gt;x&lt;/em&gt;-axis. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/ul&gt; &lt;a name=&quot;arguments&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999866&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Arguments&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999867&quot;&gt;&lt;/a&gt;&lt;code&gt;fun&lt;/code&gt; is the function whose zero is to be computed. It accepts a vector &lt;code&gt;x&lt;/code&gt; and returns a scalar &lt;code&gt;f&lt;/code&gt;, the objective function evaluated at &lt;code&gt;x&lt;/code&gt;.  The function &lt;code&gt;fun&lt;/code&gt; can be specified as a function handle.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999868&quot;&gt;&lt;/a&gt;x = fzero(@myfun,x0)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999869&quot;&gt;&lt;/a&gt;where &lt;code&gt;myfun&lt;/code&gt; is a MATLAB function such as&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999870&quot;&gt;&lt;/a&gt;function f = myfun(x)&lt;br /&gt;&lt;a name=&quot;999871&quot;&gt;&lt;/a&gt;f = ...            % Compute function value at x&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999872&quot;&gt;&lt;/a&gt;&lt;code&gt;fun&lt;/code&gt; can also be an inline object.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999873&quot;&gt;&lt;/a&gt;x = fzero(inline(&#39;sin(x*x)&#39;),x0);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999874&quot;&gt;&lt;/a&gt;Other arguments are described in the syntax descriptions above.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999875&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999876&quot;&gt;&lt;/a&gt;&lt;strong&gt;Example 1&lt;/strong&gt;. Calculate &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_f7a.gif&quot; align=&quot;bottom&quot; /&gt; by finding the zero of the sine function near 3.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999877&quot;&gt;&lt;/a&gt;x = fzero(&lt;code&gt;@&lt;/code&gt;sin,3)&lt;br /&gt;&lt;a name=&quot;999878&quot;&gt;&lt;/a&gt;x =&lt;br /&gt;&lt;a name=&quot;999879&quot;&gt;&lt;/a&gt;    3.1416&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999880&quot;&gt;&lt;/a&gt;&lt;strong&gt;Example 2&lt;/strong&gt;. To find the zero of cosine between 1 and 2&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999881&quot;&gt;&lt;/a&gt;x = fzero(&lt;code&gt;@&lt;/code&gt;cos,[1 2])&lt;br /&gt;&lt;a name=&quot;999882&quot;&gt;&lt;/a&gt;x =&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999883&quot;&gt;&lt;/a&gt;        1.5708&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999884&quot;&gt;&lt;/a&gt;Note that &lt;code&gt;cos(1)&lt;/code&gt; and &lt;code&gt;cos(2)&lt;/code&gt; differ in sign.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999888&quot;&gt;&lt;/a&gt;&lt;strong&gt;Example 3&lt;/strong&gt;. To find a zero of the function &lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/math_f40.gif&quot; align=&quot;bottom&quot; /&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999889&quot;&gt;&lt;/a&gt;write an M-file called &lt;code&gt;f&lt;/code&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;.&lt;/span&gt;&lt;code&gt;m&lt;/code&gt;.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999890&quot;&gt;&lt;/a&gt;function y = f(x)&lt;br /&gt;&lt;a name=&quot;999891&quot;&gt;&lt;/a&gt;y = x.^3-&lt;code&gt;2&lt;/code&gt;*&lt;code&gt;x-5&lt;/code&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999892&quot;&gt;&lt;/a&gt;To find the zero near 2&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999893&quot;&gt;&lt;/a&gt;z = fzero(@f&lt;code&gt;,&lt;/code&gt;2)&lt;br /&gt;&lt;a name=&quot;999894&quot;&gt;&lt;/a&gt;z =&lt;br /&gt;&lt;a name=&quot;999895&quot;&gt;&lt;/a&gt;    2.0946&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999896&quot;&gt;&lt;/a&gt;Because this function is a polynomial, the statement &lt;code&gt;roots([1 0 -2 -5])&lt;/code&gt; finds the same real zero, and a complex conjugate pair of zeros.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999897&quot;&gt;&lt;/a&gt;    2.0946&lt;br /&gt;&lt;a name=&quot;999898&quot;&gt;&lt;/a&gt;   -1.0473 + 1.1359i&lt;br /&gt;&lt;a name=&quot;999899&quot;&gt;&lt;/a&gt;   -1.0473 - 1.1359i&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;algorithm&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999900&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Algorithm&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999902&quot;&gt;&lt;/a&gt;The &lt;code&gt;fzero&lt;/code&gt; command is an M-file. The algorithm, which was originated by T. Dekker, uses a combination of bisection, secant, and inverse quadratic interpolation methods. An Algol 60 version, with some improvements.&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;/p&gt; &lt;a name=&quot;limitations&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999909&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Limitations&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999910&quot;&gt;&lt;/a&gt;The &lt;code&gt;fzero&lt;/code&gt; command finds a point where the function changes sign. If the function is &lt;em&gt;continuous&lt;/em&gt;, this is also a point where the function has a value near zero. If the function is not continuous, &lt;code&gt;fzero&lt;/code&gt; may return values that are discontinuous points instead of zeros. For example, &lt;code&gt;fzero(@tan,1)&lt;/code&gt; returns &lt;code&gt;1.5708&lt;/code&gt;, a discontinuous point in &lt;code&gt;tan&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999911&quot;&gt;&lt;/a&gt;Furthermore, the &lt;code&gt;fzero&lt;/code&gt; command defines a &lt;em&gt;zero&lt;/em&gt; as a point where the function crosses the &lt;em&gt;x&lt;/em&gt;-axis. Points where the function touches, but does not cross, the &lt;em&gt;x&lt;/em&gt;-axis are not valid zeros. For example, &lt;code&gt;y = x.^2&lt;/code&gt; is a parabola that touches the &lt;em&gt;x&lt;/em&gt;-axis at 0. Because the function never crosses the &lt;em&gt;x&lt;/em&gt;-axis, however, no zero is found. For functions with no valid zeros, &lt;code&gt;fzero&lt;/code&gt; executes until &lt;code&gt;Inf&lt;/code&gt;, &lt;code&gt;NaN&lt;/code&gt;, or a complex value is detected.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/8595535402198131685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/zero-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/8595535402198131685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/8595535402198131685'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/zero-function.html' title='zero function'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-3957596084210910687</id><published>2009-08-13T10:24:00.000-07:00</published><updated>2009-08-13T10:26:46.243-07:00</updated><title type='text'>writing function..</title><content type='html'>&lt;a style=&quot;font-weight: bold;&quot; name=&quot;353210&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;fwrite&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Write binary data to a file &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353214&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;353215&quot;&gt;&lt;/a&gt;count = fwrite(fid,A,&lt;code&gt;precision&lt;/code&gt;)&lt;br /&gt;&lt;a name=&quot;353216&quot;&gt;&lt;/a&gt;count = fwrite(fid,A,&lt;code&gt;precision&lt;/code&gt;,skip)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;368997&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;353218&quot;&gt;&lt;/a&gt;&lt;code&gt;count = fwrite(fid,A,precision) &lt;/code&gt; &lt;a name=&quot;374972&quot;&gt;&lt;/a&gt;writes the elements of matrix &lt;code&gt;A&lt;/code&gt; to the specified file, translating MATLAB values to the specified &lt;code&gt;precision&lt;/code&gt;. The data is written to the file in column order, and a &lt;code&gt;count&lt;/code&gt; is kept of the number of elements written successfully. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;414456&quot;&gt;&lt;/a&gt;&lt;code&gt;fid&lt;/code&gt; is an integer file identifier obtained from &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/fopen.html&quot;&gt;fopen&lt;/a&gt;&lt;/code&gt;, or &lt;code&gt;1&lt;/code&gt; for standard output or &lt;code&gt;2&lt;/code&gt; for standard error.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;415577&quot;&gt;&lt;/a&gt;&lt;code&gt;precision&lt;/code&gt; controls the form and size of the result. For &lt;code&gt;&#39;bitN&#39;&lt;/code&gt; or &lt;code&gt;&#39;ubitN&#39;&lt;/code&gt; precisions, &lt;code&gt;fwrite&lt;/code&gt; sets all bits in &lt;code&gt;A&lt;/code&gt; when the value is out-of-range.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;353222&quot;&gt;&lt;/a&gt;&lt;code&gt;count = fwrite(fid,A,&lt;code&gt;precision&lt;/code&gt;,skip) &lt;/code&gt; &lt;a name=&quot;353223&quot;&gt;&lt;/a&gt;includes an optional &lt;code&gt;skip&lt;/code&gt; argument that specifies the number of bytes to skip before each &lt;code&gt;precision&lt;/code&gt; value is written. With the &lt;code&gt;skip&lt;/code&gt; argument present, &lt;code&gt;fwrite&lt;/code&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt; skips and &lt;/span&gt;writes one value, skips and writes another value, etc. until all of &lt;code&gt;A&lt;/code&gt; is written. If &lt;code&gt;precision&lt;/code&gt; is a bit format like &lt;code&gt;&#39;bitN&#39;&lt;/code&gt; or &lt;code&gt;&#39;ubitN&#39;&lt;/code&gt;, &lt;code&gt;skip&lt;/code&gt; is specified in bits. This is useful for inserting data into noncontiguous fields in fixed-length records.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353410&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;353411&quot;&gt;&lt;/a&gt;For example,&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;415602&quot;&gt;&lt;/a&gt;fid = fopen(&#39;magic5.bin&#39;,&#39;wb&#39;);&lt;br /&gt;&lt;a name=&quot;353412&quot;&gt;&lt;/a&gt;fwrite(fid,magic(5),&#39;integer&lt;code&gt;*&lt;/code&gt;4&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;353413&quot;&gt;&lt;/a&gt;creates a 100-byte binary file, containing the 25 elements of the 5-by-5 magic square, stored as 4-byte integers.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;353210&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;fwrite (serial)&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;353210&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;353210&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;353210&quot;&gt;Write binary data to the device &lt;/a&gt;&lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353214&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;368995&quot;&gt;&lt;/a&gt;fwrite(obj,A)&lt;br /&gt;&lt;a name=&quot;368996&quot;&gt;&lt;/a&gt;fwrite(obj,A,&#39;&lt;code&gt;&lt;em&gt;precision&lt;/em&gt;&lt;/code&gt;&#39;)&lt;br /&gt;&lt;a name=&quot;489381&quot;&gt;&lt;/a&gt;fwrite(obj,A,&#39;&lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt;&#39;)&lt;br /&gt;&lt;a name=&quot;475843&quot;&gt;&lt;/a&gt;fwrite(obj,A,&#39;&lt;code&gt;&lt;em&gt;precision&lt;/em&gt;&lt;/code&gt;&#39;,&#39;&lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt;&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;arguments&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;380605&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Arguments&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;380619&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;2&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;380608&quot;&gt;&lt;/a&gt;&lt;code&gt;obj&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;380610&quot;&gt;&lt;/a&gt;A serial port object.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;380612&quot;&gt;&lt;/a&gt;&lt;code&gt;A&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;380614&quot;&gt;&lt;/a&gt;The binary data written to the device.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;380616&quot;&gt;&lt;/a&gt;&lt;code&gt;&#39;&lt;/code&gt;&lt;code&gt;&lt;em&gt;precision&lt;/em&gt;&lt;/code&gt;&lt;code&gt;&#39;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;380618&quot;&gt;&lt;/a&gt;The number of bits written for each value, and the interpretation of the bits as character, integer, or floating-point values.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;475838&quot;&gt;&lt;/a&gt;&lt;code&gt;&#39;&lt;/code&gt;&lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt;&lt;code&gt;&#39;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;475836&quot;&gt;&lt;/a&gt;Specifies whether data is written synchronously or asynchronously.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;368997&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;369000&quot;&gt;&lt;/a&gt;&lt;code&gt;fwrite(obj,A) &lt;/code&gt; &lt;a name=&quot;380916&quot;&gt;&lt;/a&gt;writes the binary data &lt;code&gt;A&lt;/code&gt; to the device connected to &lt;code&gt;obj&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;368886&quot;&gt;&lt;/a&gt;&lt;code&gt;fwrite(obj,A,&#39;&lt;code&gt;&lt;em&gt;precision&lt;/em&gt;&lt;/code&gt;&#39;) &lt;/code&gt; &lt;a name=&quot;368887&quot;&gt;&lt;/a&gt;writes binary data with precision specified by &lt;code&gt;&lt;em&gt;precision&lt;/em&gt;&lt;/code&gt;. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;514170&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;em&gt;precision&lt;/em&gt;&lt;/code&gt; controls the number of bits written for each value and the interpretation of those bits as integer, floating-point, or &lt;span style=&quot;font-family:sansserif;&quot;&gt;character values. &lt;/span&gt;If &lt;code&gt;&lt;em&gt;precision&lt;/em&gt;&lt;/code&gt; is not specified, &lt;code&gt;uchar&lt;/code&gt; (an 8-bit unsigned character) is used.&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;514171&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;fwrite(obj,A,&#39;&lt;/code&gt;&lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt;&lt;code&gt;&#39;) &lt;/code&gt;&lt;/code&gt; &lt;a name=&quot;489420&quot;&gt;&lt;/a&gt;writes binary data with command line access specified by &lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt;. If &lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt; is &lt;code&gt;sync&lt;/code&gt;, &lt;code&gt;A&lt;/code&gt; is written synchronously and the command line is blocked. If &lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt; is &lt;code&gt;async&lt;/code&gt;, &lt;code&gt;A&lt;/code&gt; is written asynchronously and the command line is not blocked. If &lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt; is not specified, the write operation is synchronous.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;475852&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;fwrite(obj,A,&#39;&lt;/code&gt;&lt;code&gt;&lt;em&gt;precision&lt;/em&gt;&lt;/code&gt;&lt;code&gt;&#39;,&#39;&lt;/code&gt;&lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt;&lt;code&gt;&#39;) &lt;/code&gt;&lt;/code&gt; &lt;a name=&quot;489438&quot;&gt;&lt;/a&gt;writes binary data with precision specified by &lt;code&gt;&lt;em&gt;precision&lt;/em&gt;&lt;/code&gt; and command line access specified by &lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;380639&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;422264&quot;&gt;&lt;/a&gt;Before you can write data to the device, it must be connected to &lt;code&gt;obj&lt;/code&gt; with the &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/fopenserial.html&quot;&gt;fopen&lt;/a&gt;&lt;/code&gt; function. A connected serial port object has a &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/status.html&quot;&gt;&lt;code&gt;Status&lt;/code&gt;&lt;/a&gt; property value of &lt;code&gt;open&lt;/code&gt;. An error is returned if you attempt to perform a write operation while &lt;code&gt;obj&lt;/code&gt; is not connected to the device.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;380831&quot;&gt;&lt;/a&gt;The &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/valuessent.html&quot;&gt;&lt;code&gt;ValuesSent&lt;/code&gt;&lt;/a&gt; property value is increased by the number of values written each time &lt;code&gt;fwrite&lt;/code&gt; is issued.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;449979&quot;&gt;&lt;/a&gt;An error occurs if the output buffer cannot hold all the data to be written. You can specify the size of the output buffer with the &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/outputbuffersize.html&quot;&gt;&lt;code&gt;OutputBufferSize&lt;/code&gt;&lt;/a&gt; property.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;422300&quot;&gt;&lt;/a&gt;If you use the &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/help.html&quot;&gt;help&lt;/a&gt;&lt;/code&gt; command to display help for &lt;code&gt;fwrite&lt;/code&gt;, then you need to supply the pathname shown below.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;422301&quot;&gt;&lt;/a&gt;help serial/fwrite&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;synchronous_versus_asynchronous_write_operations&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;422308&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;Synchronous Versus Asynchronous Write Operations&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;449907&quot;&gt;&lt;/a&gt;By default, data is written to the device synchronously and the command line is blocked until the operation completes. You can perform an asynchronous write by configuring the &lt;code&gt;&lt;em&gt;mode&lt;/em&gt;&lt;/code&gt; input argument to be &lt;code&gt;async&lt;/code&gt;. For asynchronous writes:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;449940&quot;&gt;&lt;/a&gt;The &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/bytestooutput.html&quot;&gt;&lt;code&gt;BytesToOutput&lt;/code&gt;&lt;/a&gt; property value is continuously updated to reflect the number of bytes in the output buffer.  &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;449943&quot;&gt;&lt;/a&gt;The M-file callback function specified for the &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/outputemptyfcn.html&quot;&gt;&lt;code&gt;OutputEmptyFcn&lt;/code&gt;&lt;/a&gt; property is executed when the output buffer is empty. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;449918&quot;&gt;&lt;/a&gt;You can determine whether an asynchronous write operation is in progress with the &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/transferstatus.html&quot;&gt;&lt;code&gt;TransferStatus&lt;/code&gt;&lt;/a&gt; property.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;512869&quot;&gt;&lt;/a&gt;Synchronous and asynchronous write operations are discussed in more detail in &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/ch_ser21.html#synch_asynch_description&quot;&gt;Writing Data&lt;/a&gt;.&lt;/p&gt; &lt;a name=&quot;rules_for_completing_a_write_operation_with_fwrite&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;455492&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;Rules for Completing a Write Operation with fwrite&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;455493&quot;&gt;&lt;/a&gt;A binary write operation using &lt;code&gt;fwrite&lt;/code&gt; completes when:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;455494&quot;&gt;&lt;/a&gt;The specified data is written. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;455496&quot;&gt;&lt;/a&gt;The time specified by the &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/timeout.html&quot;&gt;&lt;code&gt;Timeout&lt;/code&gt;&lt;/a&gt; property passes. &lt;/li&gt;&lt;/ul&gt; &lt;ul&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr width=&quot;90%&quot;&gt;&lt;td bgcolor=&quot;#ffe4b0&quot;&gt;&lt;a name=&quot;514027&quot;&gt;&lt;/a&gt;&lt;b&gt;Note  &lt;/b&gt;   The &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/terminator.html&quot;&gt;&lt;code&gt;Terminator&lt;/code&gt;&lt;/a&gt; property is not used with binary write operations. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/ul&gt; &lt;a name=&quot;supported_precisions&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;514029&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;Supported Precisions&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;a name=&quot;514157&quot;&gt;&lt;/a&gt;The supported values for &lt;code&gt;&lt;em&gt;precision&lt;/em&gt;&lt;/code&gt; are listed below.&lt;br /&gt;&lt;br /&gt; &lt;table border=&quot;2&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt;&lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514032&quot;&gt;&lt;/a&gt;&lt;b&gt;Data Type&lt;/b&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514034&quot;&gt;&lt;/a&gt;&lt;b&gt;Precision&lt;/b&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514036&quot;&gt;&lt;/a&gt;&lt;b&gt;Interpretation&lt;/b&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;3&quot;&gt;&lt;a name=&quot;514038&quot;&gt;&lt;/a&gt;Character&lt;br /&gt;&lt;!-- TBLSPANEND --&gt;&lt;/td&gt;&lt;td&gt;&lt;a name=&quot;514040&quot;&gt;&lt;/a&gt;&lt;code&gt;uchar&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514042&quot;&gt;&lt;/a&gt;8-bit unsigned character&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514046&quot;&gt;&lt;/a&gt;&lt;code&gt;schar&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514048&quot;&gt;&lt;/a&gt;8-bit signed character&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514052&quot;&gt;&lt;/a&gt;&lt;code&gt;char&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514054&quot;&gt;&lt;/a&gt;8-bit signed or unsigned character&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;12&quot;&gt;&lt;a name=&quot;514056&quot;&gt;&lt;/a&gt;Integer&lt;br /&gt;&lt;!-- TBLSPANEND --&gt;&lt;/td&gt;&lt;td&gt;&lt;a name=&quot;514058&quot;&gt;&lt;/a&gt;&lt;code&gt;int8&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514060&quot;&gt;&lt;/a&gt;8-bit integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514064&quot;&gt;&lt;/a&gt;&lt;code&gt;int16&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514066&quot;&gt;&lt;/a&gt;16-bit integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514070&quot;&gt;&lt;/a&gt;&lt;code&gt;int32&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514072&quot;&gt;&lt;/a&gt;32-bit integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514076&quot;&gt;&lt;/a&gt;&lt;code&gt;uint8&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514078&quot;&gt;&lt;/a&gt;8-bit unsigned integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514082&quot;&gt;&lt;/a&gt;&lt;code&gt;uint16&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514084&quot;&gt;&lt;/a&gt;16-bit unsigned integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514088&quot;&gt;&lt;/a&gt;&lt;code&gt;uint32&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514090&quot;&gt;&lt;/a&gt;32-bit unsigned integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514094&quot;&gt;&lt;/a&gt;&lt;code&gt;short&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514096&quot;&gt;&lt;/a&gt;16-bit integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514100&quot;&gt;&lt;/a&gt;&lt;code&gt;int&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514102&quot;&gt;&lt;/a&gt;32-bit integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514106&quot;&gt;&lt;/a&gt;&lt;code&gt;long&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514108&quot;&gt;&lt;/a&gt;32- or 64-bit integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514112&quot;&gt;&lt;/a&gt;&lt;code&gt;ushort&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514114&quot;&gt;&lt;/a&gt;16-bit unsigned integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514118&quot;&gt;&lt;/a&gt;&lt;code&gt;uint&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514120&quot;&gt;&lt;/a&gt;32-bit unsigned integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514124&quot;&gt;&lt;/a&gt;&lt;code&gt;ulong&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514126&quot;&gt;&lt;/a&gt;32- or 64-bit unsigned integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;5&quot;&gt;&lt;a name=&quot;514128&quot;&gt;&lt;/a&gt;Floating-point&lt;br /&gt;&lt;!-- TBLSPANEND --&gt;&lt;/td&gt;&lt;td&gt;&lt;a name=&quot;514130&quot;&gt;&lt;/a&gt;&lt;code&gt;single&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514132&quot;&gt;&lt;/a&gt;32-bit floating point&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514136&quot;&gt;&lt;/a&gt;&lt;code&gt;float32&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514138&quot;&gt;&lt;/a&gt;32-bit floating point&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514142&quot;&gt;&lt;/a&gt;&lt;code&gt;float&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514144&quot;&gt;&lt;/a&gt;32-bit floating point&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514148&quot;&gt;&lt;/a&gt;&lt;code&gt;double&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514150&quot;&gt;&lt;/a&gt;64-bit floating point&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;514154&quot;&gt;&lt;/a&gt;&lt;code&gt;float64&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;514156&quot;&gt;&lt;/a&gt;64-bit floating point&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;353210&quot;&gt;   &lt;!-- FNAME:fwrite (serial) --&gt;&lt;/a&gt;&lt;a name=&quot;353210&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;353211&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;353210&quot;&gt; &lt;!-- FNAME:fwrite --&gt;&lt;/a&gt;&lt;a name=&quot;353210&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a name=&quot;353211&quot;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/3957596084210910687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/writing-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/3957596084210910687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/3957596084210910687'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/writing-function.html' title='writing function..'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-9186587136055835996</id><published>2009-08-13T10:20:00.000-07:00</published><updated>2009-08-13T10:23:54.427-07:00</updated><title type='text'>funm</title><content type='html'>Evaluate general matrix function &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999766&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999767&quot;&gt;&lt;/a&gt;F = funm(A,fun)&lt;br /&gt;&lt;a name=&quot;999768&quot;&gt;&lt;/a&gt;[F,esterr] = funm(A,fun)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999769&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999770&quot;&gt;&lt;/a&gt;&lt;code&gt;F = funm(A,fun) &lt;/code&gt; &lt;a name=&quot;999773&quot;&gt;&lt;/a&gt;for a square matrix argument &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;&lt;/code&gt;evaluates the matrix version of the function &lt;code&gt;fun&lt;/code&gt;. For matrix exponentials, logarithms and square roots, use &lt;code&gt;expm(A)&lt;/code&gt;, &lt;code&gt;logm(A)&lt;/code&gt; and &lt;code&gt;sqrtm(A)&lt;/code&gt; instead.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999774&quot;&gt;&lt;/a&gt;&lt;code&gt;[F,esterr] = funm(A,fun) &lt;/code&gt; &lt;a name=&quot;999775&quot;&gt;&lt;/a&gt;does not print any message, but returns a very rough estimate of the relative error in the computed result.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999776&quot;&gt;&lt;/a&gt;If &lt;code&gt;A&lt;/code&gt; is symmetric or Hermitian, then its Schur form is diagonal and &lt;code&gt;funm&lt;/code&gt; is able to produce an accurate result.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999777&quot;&gt;&lt;/a&gt;&lt;code&gt;L = logm(A)&lt;/code&gt; uses &lt;code&gt;funm&lt;/code&gt; to do its computations, but it can get more reliable error estimates by comparing &lt;code&gt;expm(L)&lt;/code&gt; with &lt;code&gt;A&lt;/code&gt;. &lt;code&gt;S = sqrtm(A)&lt;/code&gt; and &lt;code&gt;E = expm(A)&lt;/code&gt; use completely different algorithms.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999778&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999779&quot;&gt;&lt;/a&gt;&lt;strong&gt;Example 1.&lt;/strong&gt; &lt;code&gt;fun&lt;/code&gt; can be specified using &lt;code&gt;@&lt;/code&gt;:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999780&quot;&gt;&lt;/a&gt;F = funm(magic(3),@sin)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999781&quot;&gt;&lt;/a&gt;is the matrix sine of the 3-by-3 magic matrix.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999782&quot;&gt;&lt;/a&gt;&lt;strong&gt;Example 2.&lt;/strong&gt; The statements&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999783&quot;&gt;&lt;/a&gt;S = funm(X&lt;code&gt;,&lt;/code&gt;@sin);&lt;br /&gt;&lt;a name=&quot;999784&quot;&gt;&lt;/a&gt;C = funm(X&lt;code&gt;,&lt;/code&gt;@cos);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999786&quot;&gt;&lt;/a&gt;produce the same results to within roundoff error as&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999787&quot;&gt;&lt;/a&gt;E = expm(i*X);&lt;br /&gt;&lt;a name=&quot;999788&quot;&gt;&lt;/a&gt;C = real(E);&lt;br /&gt;&lt;a name=&quot;999789&quot;&gt;&lt;/a&gt;S = imag(E);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;999790&quot;&gt;&lt;/a&gt;In either case, the results satisfy &lt;code&gt;S*S+C*C = I&lt;/code&gt;, where &lt;code&gt;I&lt;/code&gt; &lt;code&gt;=&lt;/code&gt; &lt;code&gt;eye(size(X)).&lt;/code&gt;&lt;/p&gt; &lt;a name=&quot;algorithm&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999791&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Algorithm&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999792&quot;&gt;&lt;/a&gt;&lt;code&gt;funm&lt;/code&gt; uses a potentially unstable algorithm.  If &lt;code&gt;A&lt;/code&gt; is close to a matrix with multiple eigenvalues and poorly conditioned eigenvectors, &lt;code&gt;funm&lt;/code&gt; may produce inaccurate results. An attempt is made to detect this situation and print a warning message. The error detector is sometimes too sensitive and a message is printed even though the the computed result is accurate.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/9186587136055835996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/funm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/9186587136055835996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/9186587136055835996'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/funm.html' title='funm'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-1693425261679645222</id><published>2009-08-13T10:06:00.001-07:00</published><updated>2009-08-13T10:06:44.135-07:00</updated><title type='text'>functions</title><content type='html'>Return information about a function handle &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;813407&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;813408&quot;&gt;&lt;/a&gt;f = functions(funhandle)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;813409&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;813410&quot;&gt;&lt;/a&gt;&lt;code&gt;f = functions(funhandle) &lt;/code&gt; &lt;a name=&quot;813411&quot;&gt;&lt;/a&gt;returns, in a MATLAB structure, the function name, type, filename, and other information for the function handle stored in the variable, &lt;code&gt;funhandle&lt;/code&gt;.&lt;/p&gt; &lt;ul&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr width=&quot;90%&quot;&gt;&lt;td bgcolor=&quot;#ffe4b0&quot;&gt;&lt;a name=&quot;813412&quot;&gt;&lt;/a&gt;&lt;b&gt;Note  &lt;/b&gt;   The &lt;code&gt;functions&lt;/code&gt; function is provided for querying and debugging purposes. Its behavior may change in subsequent releases, so it should not be relied upon for programming purposes. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/ul&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;828485&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;828490&quot;&gt;&lt;/a&gt;For handles to functions that overload one of the MATLAB classes, like &lt;code&gt;double&lt;/code&gt; or &lt;code&gt;char&lt;/code&gt;, the structure returned by &lt;code&gt;functions&lt;/code&gt; contains an additional field named &lt;code&gt;methods&lt;/code&gt;. The &lt;code&gt;methods&lt;/code&gt; field is a substructure containing one fieldname for each MATLAB class that overloads the function. The value of each field is the path and name of the file that defines the method.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;813413&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;813414&quot;&gt;&lt;/a&gt;To obtain information on a function handle for the &lt;code&gt;deblank&lt;/code&gt; function,&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;813415&quot;&gt;&lt;/a&gt;f = functions(@deblank)&lt;br /&gt;&lt;a name=&quot;813416&quot;&gt;&lt;/a&gt;f =&lt;br /&gt;&lt;a name=&quot;813417&quot;&gt;&lt;/a&gt;    function: &#39;deblank&#39;&lt;br /&gt;&lt;a name=&quot;813418&quot;&gt;&lt;/a&gt;        type: &#39;overloaded&#39;&lt;br /&gt;&lt;a name=&quot;813419&quot;&gt;&lt;/a&gt;        file: &#39;matlabroot\toolbox\matlab\strfun\deblank.m&#39;&lt;br /&gt;&lt;a name=&quot;813420&quot;&gt;&lt;/a&gt;     methods: [1x1 struct]&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/1693425261679645222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/functions.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/1693425261679645222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/1693425261679645222'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/functions.html' title='functions'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-1422004947258945158</id><published>2009-08-13T10:05:00.000-07:00</published><updated>2009-08-13T10:06:02.492-07:00</updated><title type='text'>function_handle (@)</title><content type='html'>MATLAB data type that is a handle to a function &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;813376&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;813377&quot;&gt;&lt;/a&gt;handle = @functionname&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;813378&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;813379&quot;&gt;&lt;/a&gt;&lt;code&gt;handle = @functionname &lt;/code&gt; &lt;a name=&quot;813380&quot;&gt;&lt;/a&gt;returns a handle to the specified MATLAB function.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;828809&quot;&gt;&lt;/a&gt;A &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_prog/ch_funha.html#function_handles&quot;&gt;function handle&lt;/a&gt; captures all the information about a function that MATLAB needs to execute that function. Typically, a function handle is passed in an argument list to other functions. The receiving functions can then execute the function through the handle that was passed in. Always use &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/feval.html&quot;&gt;feval&lt;/a&gt;&lt;/code&gt; to execute, or &lt;em&gt;evaluate&lt;/em&gt;, a function through its function handle.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;828991&quot;&gt;&lt;/a&gt;When creating a function handle, the function you specify must be on the MATLAB path and in the current scope. This condition does not apply when you evaluate the function handle. You can, for example, execute a subfunction from a separate (out of scope) M-file using a function handle, as long as the handle was created within the subfunction&#39;s M-file (in scope).&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;829136&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;828625&quot;&gt;&lt;/a&gt;For nonoverloaded functions, subfunctions, and private functions, a function handle references just the one function specified in the &lt;code&gt;@functionname&lt;/code&gt; syntax.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;813384&quot;&gt;&lt;/a&gt;When you evaluate an overloaded function through its handle, the arguments the handle is evaluated with determine the actual function that MATLAB dispatches to.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;813385&quot;&gt;&lt;/a&gt;The function handle is a standard MATLAB data type. As such, you can manipulate and operate on function handles in the same manner as on other MATLAB data types. This includes using function handles in arrays, structures, and cell arrays.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;813386&quot;&gt;&lt;/a&gt;Function handles enable you to do all of the following:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;813387&quot;&gt;&lt;/a&gt;Pass function access information to other functions &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;813389&quot;&gt;&lt;/a&gt;Allow wider access to subfunctions and private functions &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;813390&quot;&gt;&lt;/a&gt;Ensure reliability when evaluating functions &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;813391&quot;&gt;&lt;/a&gt;Reduce the number of files that define your functions &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;813392&quot;&gt;&lt;/a&gt;Improve performance in repeated operations &lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;813394&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;813395&quot;&gt;&lt;/a&gt;The following example creates a function handle for the &lt;code&gt;humps&lt;/code&gt; function and assigns it to the variable, &lt;code&gt;fhandle&lt;/code&gt;.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;813396&quot;&gt;&lt;/a&gt;fhandle = @humps;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;813397&quot;&gt;&lt;/a&gt;Pass the handle to another function in the same way you would pass any argument. This example passes the function handle just created to &lt;code&gt;fminbnd&lt;/code&gt;, which then minimizes over the interval [0.3, 1].&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;813398&quot;&gt;&lt;/a&gt;x = fminbnd(fhandle, 0.3, 1)&lt;br /&gt;&lt;a name=&quot;813399&quot;&gt;&lt;/a&gt;x =&lt;br /&gt;&lt;a name=&quot;813400&quot;&gt;&lt;/a&gt;    0.6370&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;825411&quot;&gt;&lt;/a&gt;The &lt;code&gt;fminbnd&lt;/code&gt; function evaluates the &lt;code&gt;@humps&lt;/code&gt; function handle using &lt;code&gt;feval&lt;/code&gt;. A small portion of the &lt;code&gt;fminbnd&lt;/code&gt; M-file is shown below. In line 1, the &lt;code&gt;funfcn&lt;/code&gt; input parameter receives the function handle, &lt;code&gt;@humps&lt;/code&gt;, that was passed in. The &lt;code&gt;feval&lt;/code&gt; statement, in line 113, evaluates the handle.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;825412&quot;&gt;&lt;/a&gt;1    function [xf,fval,exitflag,output] = ...&lt;br /&gt;&lt;a name=&quot;825413&quot;&gt;&lt;/a&gt;         fminbnd(funfcn,ax,bx,options,varargin)&lt;br /&gt;&lt;a name=&quot;825414&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;b&gt;            .&lt;br /&gt;&lt;/b&gt;&lt;/code&gt;&lt;a name=&quot;825415&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;b&gt;            .&lt;br /&gt;&lt;/b&gt;&lt;/code&gt;&lt;a name=&quot;825416&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;b&gt;            .&lt;br /&gt;&lt;/b&gt;&lt;/code&gt;&lt;a name=&quot;825417&quot;&gt;&lt;/a&gt;113  fx = feval(funfcn,x,varargin{:});&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/1422004947258945158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/functionhandle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/1422004947258945158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/1422004947258945158'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/functionhandle.html' title='function_handle (@)'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-8984737222280874403</id><published>2009-08-13T10:04:00.000-07:00</published><updated>2009-08-13T10:05:01.744-07:00</updated><title type='text'>function</title><content type='html'>Function M-files &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;813333&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;813334&quot;&gt;&lt;/a&gt;You add new functions to the MATLAB vocabulary by expressing them in terms of existing functions. The existing commands and functions that compose the new function reside in a text file called an &lt;em&gt;M-file&lt;/em&gt;. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;813338&quot;&gt;&lt;/a&gt;M-files can be either &lt;em&gt;scripts&lt;/em&gt; or &lt;em&gt;f&lt;/em&gt;&lt;em&gt;unctions&lt;/em&gt;. Scripts are simply files containing a sequence of MATLAB statements. Functions make use of their own local variables and accept input arguments.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;813341&quot;&gt;&lt;/a&gt;The name of an M-file begins with an alphabetic character, and has a filename extension of .&lt;code&gt;m&lt;/code&gt; . The M-file name, less its extension, is what MATLAB searches for when you try to use the script or function.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;813343&quot;&gt;&lt;/a&gt;A line at the top of a function M-file contains the syntax definition. The name of a function, as defined in the first line of the&lt;span style=&quot;font-family:sansserif;&quot;&gt; M-&lt;/span&gt;file, should be the same as the name of the file without the &lt;code&gt;.m&lt;/code&gt; extension. For example, the existence of a file on disk called &lt;code&gt;stat&lt;/code&gt;.&lt;code&gt;m&lt;/code&gt; with&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;813344&quot;&gt;&lt;/a&gt;function [mean&lt;code&gt;,&lt;/code&gt;stdev] = stat(x)&lt;br /&gt;&lt;a name=&quot;813345&quot;&gt;&lt;/a&gt;n = length(x);&lt;br /&gt;&lt;a name=&quot;813346&quot;&gt;&lt;/a&gt;mean = sum(x)/n;&lt;br /&gt;&lt;a name=&quot;813347&quot;&gt;&lt;/a&gt;stdev = sqrt(sum((x-mean).^2/n));&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;813348&quot;&gt;&lt;/a&gt;defines a new function called &lt;code&gt;stat&lt;/code&gt; that calculates the mean and standard deviation of a vector. The variables within the body of the function are all local variables.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;813351&quot;&gt;&lt;/a&gt;A &lt;em&gt;subfunction&lt;/em&gt;,visible only to the other functions in the same file, is created by defining a new function with the &lt;code&gt;function&lt;/code&gt; keyword after the body of the preceding function or subfunction. For example, &lt;code&gt;avg&lt;/code&gt; is a subfunction within the file &lt;code&gt;stat.m&lt;/code&gt;:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;813352&quot;&gt;&lt;/a&gt;function [mean,stdev] = stat(x)&lt;br /&gt;&lt;a name=&quot;813353&quot;&gt;&lt;/a&gt;n = length(x);&lt;br /&gt;&lt;a name=&quot;813354&quot;&gt;&lt;/a&gt;mean = avg(x,n);&lt;br /&gt;&lt;a name=&quot;813355&quot;&gt;&lt;/a&gt;stdev = sqrt(sum((x-avg(x,n)).^2)/n);&lt;br /&gt;&lt;a name=&quot;813356&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;813357&quot;&gt;&lt;/a&gt;function mean = avg(x,n)&lt;br /&gt;&lt;a name=&quot;813358&quot;&gt;&lt;/a&gt;mean = sum(x)/n;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;813359&quot;&gt;&lt;/a&gt;Subfunctions are not visible outside the file where they are defined. Functions normally return when the end of the function is reached. Use a &lt;code&gt;return&lt;/code&gt; statement to force an early return.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;813360&quot;&gt;&lt;/a&gt;When MATLAB does not recognize a function by name, it searches for a file of the same name on disk. If the function is found, MATLAB compiles it into memory for subsequent use. In general, if you input the name of something to MATLAB, the MATLAB interpreter:&lt;/p&gt; &lt;ol start=&quot;1&quot;&gt;&lt;li&gt;&lt;a name=&quot;813362&quot;&gt;&lt;/a&gt;Checks to see if the name is a variable. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;813363&quot;&gt;&lt;/a&gt;Checks to see if the name is an internal function (&lt;code&gt;eig&lt;/code&gt;, &lt;code&gt;sin&lt;/code&gt;) that was not overloaded. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;813364&quot;&gt;&lt;/a&gt;Checks to see if the name is a local function (local in sense of multifunction file). &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;813365&quot;&gt;&lt;/a&gt;Checks to see if the name is a function in a private directory. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;813366&quot;&gt;&lt;/a&gt;Locates any and all occurrences of function in method&lt;code&gt; &lt;/code&gt;directories and on the path. Order is of no importance.  &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;a name=&quot;813367&quot;&gt;&lt;/a&gt;At execution, MATLAB:&lt;/p&gt; &lt;ol start=&quot;6&quot;&gt;&lt;li&gt;&lt;a name=&quot;813368&quot;&gt;&lt;/a&gt;Checks to see if the name is wired to a specific function (2, 3, &amp;amp; 4 above) &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;813369&quot;&gt;&lt;/a&gt;Uses precedence rules to determine which instance from 5 above to call (we may default to an internal MATLAB function). Constructors have higher precedence than anything else. &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;a name=&quot;813370&quot;&gt;&lt;/a&gt;When you call an M-file function from the command line or from within another M-file, MATLAB parses the function and stores it in memory. The parsed function remains in memory until cleared with the clear command or you &lt;code&gt;quit&lt;/code&gt; MATLAB. The &lt;code&gt;pcode&lt;/code&gt; command performs the parsing step and stores the result on the disk as a P-file to be loaded later.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/8984737222280874403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/8984737222280874403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/8984737222280874403'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/function.html' title='function'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-3795474614362554123</id><published>2009-08-13T10:03:00.000-07:00</published><updated>2009-08-13T10:04:01.432-07:00</updated><title type='text'>func2str</title><content type='html'>Constructs a function name string from a function handle &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;813314&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;813315&quot;&gt;&lt;/a&gt;s = func2str(fhandle)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;813316&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;813317&quot;&gt;&lt;/a&gt;&lt;code&gt;func2str(fhandle) &lt;/code&gt; &lt;a name=&quot;813318&quot;&gt;&lt;/a&gt;constructs a string, &lt;code&gt;s&lt;/code&gt;, that holds the name of the function to which the function handle, &lt;code&gt;fhandle&lt;/code&gt;, belongs.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;813319&quot;&gt;&lt;/a&gt;When you need to perform a string operation, such as compare or display, on a function handle, you can use &lt;code&gt;func2str&lt;/code&gt; to construct a string bearing the function name.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;813320&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;813321&quot;&gt;&lt;/a&gt;To create a function name string from the function handle, &lt;code&gt;@humps&lt;/code&gt;&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;813322&quot;&gt;&lt;/a&gt;funname = func2str(@humps)&lt;br /&gt;&lt;a name=&quot;813323&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;813324&quot;&gt;&lt;/a&gt;funname =&lt;br /&gt;&lt;a name=&quot;813325&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;813326&quot;&gt;&lt;/a&gt;humps&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/3795474614362554123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/func2str.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/3795474614362554123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/3795474614362554123'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/func2str.html' title='func2str'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-4966988525961136858</id><published>2009-08-13T10:02:00.000-07:00</published><updated>2009-08-13T10:03:30.114-07:00</updated><title type='text'>fullfile</title><content type='html'>Build a full filename from parts &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;433722&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;433723&quot;&gt;&lt;/a&gt;fullfile(&#39;dir1&#39;,&#39;dir2&#39;,...,&#39;filename&#39;)&lt;br /&gt;&lt;a name=&quot;433724&quot;&gt;&lt;/a&gt;f = fullfile(&#39;dir1&#39;,&#39;dir2&#39;,...,&#39;filename&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;433725&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;433726&quot;&gt;&lt;/a&gt;&lt;code&gt;fullfile(dir1,dir2,...,filename) &lt;/code&gt; &lt;a name=&quot;433728&quot;&gt;&lt;/a&gt;builds a full filename from the directories and filename specified. This is conceptually equivalent to&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;433729&quot;&gt;&lt;/a&gt;&lt;code&gt;f = &lt;/code&gt;[dir1 dirsep dir2 dirsep ... dirsep filename]&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;433730&quot;&gt;&lt;/a&gt;except that care is taken to handle the cases when the directories begin or end with a directory separator.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;433731&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;433732&quot;&gt;&lt;/a&gt;To create the full filename from a disk name, directories, and filename,&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;433733&quot;&gt;&lt;/a&gt;f = fullfile(&#39;C:&#39;,&#39;Applications&#39;,&#39;matlab&#39;,&#39;myfun.m&#39;)&lt;br /&gt;&lt;a name=&quot;433734&quot;&gt;&lt;/a&gt;f =&lt;br /&gt;&lt;a name=&quot;433735&quot;&gt;&lt;/a&gt;C:\Applications\matlab\myfun.m&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;433736&quot;&gt;&lt;/a&gt;The following examples both produce the same result on UNIX, but only the second one works on all platforms.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;433737&quot;&gt;&lt;/a&gt;&lt;code&gt;fullfile(matlabroot,&#39;toolbox/matlab/general/Contents.m&#39;) &lt;/code&gt;and&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;433738&quot;&gt;&lt;/a&gt;&lt;code&gt;fullfile(matlabroot,&#39;toolbox&#39;,&#39;matlab&#39;,&#39;general&#39;,&#39;Contents.m&#39;)&lt;/code&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/4966988525961136858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/fullfile.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/4966988525961136858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/4966988525961136858'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/fullfile.html' title='fullfile'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-1833953273496177652</id><published>2009-08-13T09:59:00.000-07:00</published><updated>2009-08-13T10:00:16.282-07:00</updated><title type='text'>ftell</title><content type='html'>Get file position indicator &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353200&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;353201&quot;&gt;&lt;/a&gt;position = ftell(fid)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353202&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;353203&quot;&gt;&lt;/a&gt;&lt;code&gt;position = ftell(fid) &lt;/code&gt; &lt;a name=&quot;353205&quot;&gt;&lt;/a&gt;returns the location of the file position indicator for the file specified by &lt;code&gt;fid&lt;/code&gt;, an integer file identifier obtained from &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/fopen.html&quot;&gt;fopen&lt;/a&gt;&lt;/code&gt;. The &lt;code&gt;position&lt;/code&gt; is a nonnegative integer specified in bytes from the beginning of the file. A returned value of &lt;code&gt;-1&lt;/code&gt; for &lt;code&gt;position&lt;/code&gt; indicates that the query was unsuccessful; use &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/ferror.html&quot;&gt;ferror&lt;/a&gt;&lt;/code&gt; to determine the nature of the error.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999709&quot;&gt;&lt;span style=&quot;font-size:+3;color:#990000;&quot;&gt;full&lt;/span&gt;   &lt;!-- FNAME:full --&gt;&lt;/a&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999709&quot;&gt;&lt;/a&gt;  &lt;!-- SYNCHTO: func_by_.html --&gt;   &lt;!-- H2 --&gt;&lt;a style=&quot;font-weight: bold;&quot; name=&quot;999710&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999711&quot;&gt;&lt;/a&gt;Convert sparse matrix to full matrix&lt;/p&gt; &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999712&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;999713&quot;&gt;&lt;/a&gt;A = full(S)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999714&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999715&quot;&gt;&lt;/a&gt;&lt;code&gt;A = full(S) &lt;/code&gt; &lt;a name=&quot;999716&quot;&gt;&lt;/a&gt;converts a sparse matrix &lt;code&gt;S&lt;/code&gt; to full storage organization. If &lt;code&gt;S&lt;/code&gt; is a full matrix, it is left unchanged. If &lt;code&gt;A&lt;/code&gt; is full, &lt;code&gt;issparse(A)&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999717&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999718&quot;&gt;&lt;/a&gt;Let &lt;code&gt;X&lt;/code&gt; be an &lt;code&gt;m&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix with &lt;code&gt;nz&lt;/code&gt; &lt;code&gt;=&lt;/code&gt; &lt;code&gt;nnz(X)&lt;/code&gt; nonzero entries. Then &lt;code&gt;full(X)&lt;/code&gt; requires space to store &lt;code&gt;m*n&lt;/code&gt; real numbers while &lt;code&gt;sparse(X)&lt;/code&gt; requires space to store &lt;code&gt;nz&lt;/code&gt; real numbers and &lt;code&gt;(nz+n)&lt;/code&gt; integers. &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;999719&quot;&gt;&lt;/a&gt;On most computers, a real number requires twice as much storage as an integer. On such computers, &lt;code&gt;sparse(X)&lt;/code&gt; requires less storage than &lt;code&gt;full(X)&lt;/code&gt; if the density, &lt;code&gt;nnz/prod(size(X))&lt;/code&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;, &lt;/span&gt;is less than one third. Operations on sparse matrices, however, require more execution time per element than those on full matrices, so density should be considerably less than two-thirds before sparse storage is used.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;999721&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;999722&quot;&gt;&lt;/a&gt;Here is an example of a sparse matrix with a density of abou&lt;span style=&quot;font-family:sansserif;&quot;&gt;t two-thirds. &lt;/span&gt;&lt;code&gt;sparse(S)&lt;/code&gt; and &lt;code&gt;full(S)&lt;/code&gt; require about the same number of bytes of storage.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;1015367&quot;&gt;&lt;/a&gt;S = sparse(+(rand(200,200) &lt; 2/3));&lt;br /&gt;&lt;a name=&quot;999724&quot;&gt;&lt;/a&gt;A = full(S);&lt;br /&gt;&lt;a name=&quot;999725&quot;&gt;&lt;/a&gt;whos&lt;br /&gt;&lt;a name=&quot;999726&quot;&gt;&lt;/a&gt;Name     Size      Bytes   Class&lt;br /&gt;&lt;a name=&quot;999727&quot;&gt;&lt;/a&gt;  A    200X200   320000   double array&lt;br /&gt;&lt;a name=&quot;999728&quot;&gt;&lt;/a&gt;  S    200X200   318432   double array (sparse)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/1833953273496177652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/ftell.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/1833953273496177652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/1833953273496177652'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/ftell.html' title='ftell'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-7927736037487131929</id><published>2009-08-13T09:56:00.000-07:00</published><updated>2009-08-13T09:59:09.426-07:00</updated><title type='text'>fseek</title><content type='html'>Set file position indicator &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353123&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;353124&quot;&gt;&lt;/a&gt;status = fseek(fid,offset,origin)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353125&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;353126&quot;&gt;&lt;/a&gt;&lt;code&gt;status = fseek(fid,offset,origin) &lt;/code&gt; &lt;a name=&quot;353128&quot;&gt;&lt;/a&gt;repositions the file position indicator in the file with the given &lt;code&gt;fid&lt;/code&gt; to the byte with the specified &lt;code&gt;offset&lt;/code&gt; relative to &lt;code&gt;origin&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;453210&quot;&gt;&lt;/a&gt;For a file having &lt;code&gt;n&lt;/code&gt; bytes, the bytes are numbered from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;n-1&lt;/code&gt;. The position immediately following the last byte is the end of the file, or &lt;code&gt;eof&lt;/code&gt;, position. You would seek to the &lt;code&gt;eof&lt;/code&gt; position if you wanted to add data to the end of a file.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;453213&quot;&gt;&lt;/a&gt;This figure represents a file having 12 bytes, numbered 0 through 11. The first command shown seeks to the ninth byte of data in the file. The second command seeks just past the end of the file data, to the &lt;code&gt;eof&lt;/code&gt; position. &lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/fileio2a.gif&quot; align=&quot;bottom&quot; /&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;453232&quot;&gt;&lt;/a&gt;&lt;code&gt;fseek&lt;/code&gt; does not seek beyond the end of file, &lt;code&gt;eof&lt;/code&gt;, position. If you attempt to seek beyond &lt;code&gt;eof&lt;/code&gt;, MATLAB returns an error status.&lt;/p&gt; &lt;a name=&quot;arguments&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353129&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Arguments&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- SEEALSO  --&gt;&lt;code&gt;&lt;!-- TBLSTART --&gt; &lt;/code&gt;&lt;table border=&quot;2&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353132&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;fid&lt;/code&gt; &lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td colspan=&quot;2&quot; rowspan=&quot;1&quot;&gt;&lt;a name=&quot;353134&quot;&gt;&lt;/a&gt;An integer file identifier obtained from &lt;code&gt;fopen&lt;/code&gt;.&lt;br /&gt;&lt;!-- TBLSPANEND --&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353138&quot;&gt;&lt;/a&gt;&lt;code&gt;offset&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td colspan=&quot;2&quot; rowspan=&quot;1&quot;&gt;&lt;a name=&quot;353140&quot;&gt;&lt;/a&gt;A value that is interpreted as follows:&lt;br /&gt;&lt;!-- TBLSPANEND --&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353144&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353146&quot;&gt;&lt;/a&gt;&lt;code&gt;offset &gt; 0&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353148&quot;&gt;&lt;/a&gt;Move position indicator &lt;code&gt;offset&lt;/code&gt; bytes toward the end of the file.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353150&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353152&quot;&gt;&lt;/a&gt;&lt;code&gt;offset = 0&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353154&quot;&gt;&lt;/a&gt;Do not change position.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353156&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353158&quot;&gt;&lt;/a&gt;&lt;code&gt;offset &lt;&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353160&quot;&gt;&lt;/a&gt;Move position indicator &lt;code&gt;offset&lt;/code&gt; bytes toward the beginning of the file.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353162&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;origin&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td colspan=&quot;2&quot; rowspan=&quot;1&quot;&gt;&lt;a name=&quot;353164&quot;&gt;&lt;/a&gt;A string whose legal values are:&lt;br /&gt;&lt;!-- TBLSPANEND --&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353168&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353170&quot;&gt;&lt;/a&gt;&lt;code&gt;&#39;bof&#39;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353172&quot;&gt;&lt;/a&gt;-&lt;code&gt;1: &lt;/code&gt;Beginning of file.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353174&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353176&quot;&gt;&lt;/a&gt;&lt;code&gt;&#39;cof&#39;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353178&quot;&gt;&lt;/a&gt;&lt;code&gt;0&lt;/code&gt;:&lt;code&gt; &lt;/code&gt;Current position in file.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353180&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353182&quot;&gt;&lt;/a&gt;&lt;code&gt;&#39;eof&#39;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353184&quot;&gt;&lt;/a&gt;&lt;code&gt;1&lt;/code&gt;: End of file.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353186&quot;&gt;&lt;/a&gt;&lt;code&gt;status&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td colspan=&quot;2&quot; rowspan=&quot;1&quot;&gt;&lt;a name=&quot;353188&quot;&gt;&lt;/a&gt;A returned value that is &lt;code&gt;0&lt;/code&gt; if the &lt;code&gt;fseek&lt;/code&gt; operation is successful and -&lt;code&gt;1&lt;/code&gt; if it fails.&lt;br /&gt;&lt;!-- TBLSPANEND --&gt;  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;    &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;452517&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;452518&quot;&gt;&lt;/a&gt;This example opens the file &lt;code&gt;test1.dat&lt;/code&gt;, seeks to the 20th byte, reads fifty 32-bit, unsigned integers into variable &lt;code&gt;A&lt;/code&gt;, and closes the file. It then opens a second file, &lt;code&gt;test2.dat&lt;/code&gt;, seeks to the end-of-file position, appends the data in &lt;code&gt;A&lt;/code&gt; to the end of this file, and closes the file.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;453432&quot;&gt;&lt;/a&gt;fid = fopen(&#39;test1.dat&#39;, &#39;r&#39;);&lt;br /&gt;&lt;a name=&quot;453436&quot;&gt;&lt;/a&gt;fseek(fid, 19, &#39;bof&#39;);&lt;br /&gt;&lt;a name=&quot;453437&quot;&gt;&lt;/a&gt;A = fread(fid, 50, &#39;uint32&#39;);&lt;br /&gt;&lt;a name=&quot;453451&quot;&gt;&lt;/a&gt;fclose(fid);&lt;br /&gt;&lt;a name=&quot;453438&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;453447&quot;&gt;&lt;/a&gt;fid = fopen(&#39;test2.dat&#39;, &#39;r+&#39;);&lt;br /&gt;&lt;a name=&quot;453445&quot;&gt;&lt;/a&gt;fseek(fid, 0, &#39;eof&#39;);&lt;br /&gt;&lt;a name=&quot;453441&quot;&gt;&lt;/a&gt;fwrite(fid, A, &#39;uint32&#39;);&lt;br /&gt;&lt;a name=&quot;453442&quot;&gt;&lt;/a&gt;fclose(fid);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/7927736037487131929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/fseek.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/7927736037487131929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/7927736037487131929'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/fseek.html' title='fseek'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-8482997438026485535</id><published>2009-08-09T10:21:00.001-07:00</published><updated>2009-08-09T10:21:44.684-07:00</updated><title type='text'>fscanf (serial)</title><content type='html'>Read data from the device, and format as text &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353000&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;367177&quot;&gt;&lt;/a&gt;A = fscanf(obj)&lt;br /&gt;&lt;a name=&quot;430970&quot;&gt;&lt;/a&gt;A = fscanf(obj,&#39;&lt;code&gt;&lt;em&gt;format&lt;/em&gt;&lt;/code&gt;&#39;)&lt;br /&gt;&lt;a name=&quot;367182&quot;&gt;&lt;/a&gt;A = fscanf(obj,&#39;&lt;code&gt;&lt;em&gt;format&lt;/em&gt;&lt;/code&gt;&#39;,size)&lt;br /&gt;&lt;a name=&quot;449882&quot;&gt;&lt;/a&gt;[A,count] = fscanf(...)&lt;br /&gt;&lt;a name=&quot;449880&quot;&gt;&lt;/a&gt;[A,count,msg] = fscanf(...)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;arguments&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;380499&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Arguments&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;380517&quot;&gt;&lt;/a&gt; &lt;!-- TBLSTART --&gt; &lt;table border=&quot;2&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;380502&quot;&gt;&lt;/a&gt;&lt;code&gt;obj&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;380504&quot;&gt;&lt;/a&gt;A serial port object.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;380532&quot;&gt;&lt;/a&gt;&lt;code&gt;&#39;&lt;/code&gt;&lt;code&gt;&lt;em&gt;format&lt;/em&gt;&lt;/code&gt;&lt;code&gt;&#39;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;380534&quot;&gt;&lt;/a&gt;C language conversion specification.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;380506&quot;&gt;&lt;/a&gt;&lt;code&gt;size&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;380508&quot;&gt;&lt;/a&gt;The number of values to read.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;380514&quot;&gt;&lt;/a&gt;&lt;code&gt;A&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;380516&quot;&gt;&lt;/a&gt;Data read from the device and formatted as text.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;449873&quot;&gt;&lt;/a&gt;&lt;code&gt;count&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;449875&quot;&gt;&lt;/a&gt;The number of values read.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;449877&quot;&gt;&lt;/a&gt;&lt;code&gt;msg&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;449879&quot;&gt;&lt;/a&gt;A message indicating if the read operation was unsuccessful.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;367124&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;430977&quot;&gt;&lt;/a&gt;&lt;code&gt;A = fscanf(obj) &lt;/code&gt; &lt;a name=&quot;430978&quot;&gt;&lt;/a&gt;reads data from the device connected to &lt;code&gt;obj&lt;/code&gt;, and returns it to &lt;code&gt;A&lt;/code&gt;. The data is converted to text using the &lt;code&gt;%c&lt;/code&gt; format.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;505958&quot;&gt;&lt;/a&gt;&lt;code&gt;A = fscanf(obj,&#39;&lt;code&gt;&lt;em&gt;format&lt;/em&gt;&lt;/code&gt;&#39;) &lt;/code&gt; &lt;a name=&quot;505959&quot;&gt;&lt;/a&gt;reads data and converts it according to &lt;code&gt;&lt;em&gt;format&lt;/em&gt;&lt;/code&gt;. &lt;code&gt;&lt;em&gt;format&lt;/em&gt;&lt;/code&gt; is a C language conversion specification. Conversion specifications involve the &lt;code&gt;%&lt;/code&gt; character and the conversion characters d, i, o, u, x, X, f, e, E, g, G, c, and s. Refer to the &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/sscanf.html&quot;&gt;sscanf&lt;/a&gt;&lt;/code&gt; file I/O format specifications or a C manual for more information.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;367187&quot;&gt;&lt;/a&gt;&lt;code&gt;A = fscanf(obj,&#39;&lt;code&gt;&lt;em&gt;format&lt;/em&gt;&lt;/code&gt;&#39;,&lt;code&gt;size&lt;/code&gt;) &lt;/code&gt; &lt;a name=&quot;368831&quot;&gt;&lt;/a&gt;reads the number of values specified by &lt;code&gt;size&lt;/code&gt;. Valid options for &lt;code&gt;size&lt;/code&gt; are:&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;2&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;368516&quot;&gt;&lt;/a&gt;&lt;code&gt;n&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;368518&quot;&gt;&lt;/a&gt;Read at most &lt;code&gt;n&lt;/code&gt; values into a column vector.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;368520&quot;&gt;&lt;/a&gt;&lt;code&gt;[m,n]&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;368525&quot;&gt;&lt;/a&gt;Read at most m-by-n values filling an m-by-n matrix in column order.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;368510&quot;&gt;&lt;/a&gt;&lt;code&gt;size&lt;/code&gt; cannot be &lt;code&gt;inf&lt;/code&gt;, and an error is returned if the specified number of values cannot be stored in the input buffer. If &lt;code&gt;size&lt;/code&gt; is not of the form &lt;code&gt;[m,n]&lt;/code&gt;, and a character conversion is specified, then &lt;code&gt;A&lt;/code&gt; is returned as a row vector. You specify the size, in bytes, of the input buffer with the &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/inputbuffersize.html&quot;&gt;&lt;code&gt;InputBufferSize&lt;/code&gt;&lt;/a&gt; property. An ASCII value is one byte.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;449846&quot;&gt;&lt;/a&gt;&lt;code&gt;[A,count] = fscanf(...) &lt;/code&gt; &lt;a name=&quot;449847&quot;&gt;&lt;/a&gt;returns the number of values read to &lt;code&gt;count&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;449848&quot;&gt;&lt;/a&gt;&lt;code&gt;[A,count,msg] = fscanf(...) &lt;/code&gt; &lt;a name=&quot;449849&quot;&gt;&lt;/a&gt;returns a warning message to &lt;code&gt;msg&lt;/code&gt; if the read operation did not complete successfully.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;380558&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;434753&quot;&gt;&lt;/a&gt;Before you can read data from the device, it must be connected to &lt;code&gt;obj&lt;/code&gt; with the &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/fopenserial.html&quot;&gt;fopen&lt;/a&gt;&lt;/code&gt; function. A connected serial port object has a &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/status.html&quot;&gt;&lt;code&gt;Status&lt;/code&gt;&lt;/a&gt; property value of &lt;code&gt;open&lt;/code&gt;. An error is returned if you attempt to perform a read operation while &lt;code&gt;obj&lt;/code&gt; is not connected to the device.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;449859&quot;&gt;&lt;/a&gt;If &lt;code&gt;msg&lt;/code&gt; is not included as an output argument and the read operation was not successful, then a warning message is returned to the command line.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;422201&quot;&gt;&lt;/a&gt;The &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/valuesreceived.html&quot;&gt;&lt;code&gt;ValuesReceived&lt;/code&gt;&lt;/a&gt; property value is increased by the number of values read - including the terminator - each time &lt;code&gt;fscanf&lt;/code&gt; is issued.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;420481&quot;&gt;&lt;/a&gt;If you use the &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/help.html&quot;&gt;help&lt;/a&gt;&lt;/code&gt; command to display help for &lt;code&gt;fscanf&lt;/code&gt;, then you need to supply the pathname shown below.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;420482&quot;&gt;&lt;/a&gt;help serial/fscanf&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;rules_for_completing_a_read_operation_with_fscanf&quot;&gt;&lt;/a&gt;&lt;!-- H3 --&gt;&lt;a name=&quot;449811&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&lt;b&gt;Rules for Completing a Read Operation with fscanf&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;449812&quot;&gt;&lt;/a&gt;A read operation with &lt;code&gt;fscanf&lt;/code&gt; blocks access to the MATLAB command line until:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a name=&quot;449832&quot;&gt;&lt;/a&gt;The terminator specified by the &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/terminator.html&quot;&gt;&lt;code&gt;Terminator&lt;/code&gt;&lt;/a&gt; property is read. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;449815&quot;&gt;&lt;/a&gt;The time specified by the &lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/matlab_external/timeout.html&quot;&gt;&lt;code&gt;Timeout&lt;/code&gt;&lt;/a&gt; property passes. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;522812&quot;&gt;&lt;/a&gt;The number of values specified by &lt;code&gt;size&lt;/code&gt; is read. &lt;/li&gt;&lt;li&gt;&lt;a name=&quot;522810&quot;&gt;&lt;/a&gt;The input buffer is filled (unless &lt;code&gt;size&lt;/code&gt; is specified) &lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;example&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353104&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;489147&quot;&gt;&lt;/a&gt;Create the serial port object &lt;code&gt;s&lt;/code&gt; and connect &lt;code&gt;s&lt;/code&gt; to a Tektronix TDS 210 oscilloscope, which is displaying sine wave.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;489148&quot;&gt;&lt;/a&gt;s = serial(&#39;COM1&#39;);&lt;br /&gt;&lt;a name=&quot;489149&quot;&gt;&lt;/a&gt;fopen(s)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;489316&quot;&gt;&lt;/a&gt;Use the &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/fprintfserial.html&quot;&gt;fprintf&lt;/a&gt;&lt;/code&gt; function to configure the scope to measure the peak-to-peak voltage of the sine wave, return the measurement type, and return the peak-to-peak voltage.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;489317&quot;&gt;&lt;/a&gt;fprintf(s,&#39;MEASUREMENT:IMMED:TYPE PK2PK&#39;)&lt;br /&gt;&lt;a name=&quot;489318&quot;&gt;&lt;/a&gt;fprintf(s,&#39;MEASUREMENT:IMMED:TYPE?&#39;)&lt;br /&gt;&lt;a name=&quot;489319&quot;&gt;&lt;/a&gt;fprintf(s,&#39;MEASUREMENT:IMMED:VALUE?&#39;)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;489320&quot;&gt;&lt;/a&gt;Because the default value for the &lt;code&gt;ReadAsyncMode&lt;/code&gt; property is &lt;code&gt;continuous&lt;/code&gt;, data associated with the two query commands is automatically returned to the input buffer.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;489152&quot;&gt;&lt;/a&gt;s.BytesAvailable&lt;br /&gt;&lt;a name=&quot;489338&quot;&gt;&lt;/a&gt;ans =&lt;br /&gt;&lt;a name=&quot;489339&quot;&gt;&lt;/a&gt;    21&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;489340&quot;&gt;&lt;/a&gt;Use &lt;code&gt;fscanf&lt;/code&gt; to read the measurement type. The operation will complete when the first terminator is read.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;489156&quot;&gt;&lt;/a&gt;meas = fscanf(s)&lt;br /&gt;&lt;a name=&quot;489356&quot;&gt;&lt;/a&gt;meas =&lt;br /&gt;&lt;a name=&quot;489354&quot;&gt;&lt;/a&gt;PK2PK&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;489369&quot;&gt;&lt;/a&gt;Use &lt;code&gt;fscanf&lt;/code&gt; to read the peak-to-peak voltage as a floating-point number, and exclude the terminator.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;489157&quot;&gt;&lt;/a&gt;pk2pk = fscanf(s,&#39;%e&#39;,14)&lt;br /&gt;&lt;a name=&quot;489270&quot;&gt;&lt;/a&gt;pk2pk =&lt;br /&gt;&lt;a name=&quot;489268&quot;&gt;&lt;/a&gt;    2.0200&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;489162&quot;&gt;&lt;/a&gt;Disconnect &lt;code&gt;s&lt;/code&gt; from the scope, and remove &lt;code&gt;s&lt;/code&gt; from memory and the workspace.&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;489163&quot;&gt;&lt;/a&gt;fclose(s)&lt;br /&gt;&lt;a name=&quot;489380&quot;&gt;&lt;/a&gt;delete(s)&lt;br /&gt;&lt;a name=&quot;489164&quot;&gt;&lt;/a&gt;clear s&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/8482997438026485535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/fscanf-serial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/8482997438026485535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/8482997438026485535'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/fscanf-serial.html' title='fscanf (serial)'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-1019796809905661218</id><published>2009-08-09T10:19:00.000-07:00</published><updated>2009-08-09T10:20:52.278-07:00</updated><title type='text'>fscanf</title><content type='html'>Read formatted data from file &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353000&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;367122&quot;&gt;&lt;/a&gt;A = fscanf(fid,format)&lt;br /&gt;&lt;a name=&quot;367123&quot;&gt;&lt;/a&gt;[A,count] = fscanf(fid,format,size)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;367124&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;368698&quot;&gt;&lt;/a&gt;&lt;code&gt;A = fscanf(fid,format) &lt;/code&gt; &lt;a name=&quot;374606&quot;&gt;&lt;/a&gt;reads all the data from the file specified by &lt;code&gt;fid&lt;/code&gt;, converts it according to the specified &lt;code&gt;format&lt;/code&gt; string, and returns it in matrix &lt;code&gt;A&lt;/code&gt;. Argument &lt;code&gt;fid&lt;/code&gt; is an integer file identifier obtained from &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/fopen.html&quot;&gt;fopen&lt;/a&gt;&lt;/code&gt;. &lt;code&gt;format&lt;/code&gt; is a string specifying the format of the data to be read. See &quot;Remarks&quot; for details.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;368699&quot;&gt;&lt;/a&gt;&lt;code&gt;[A,count] = fscanf(fid,format,size) &lt;/code&gt; &lt;a name=&quot;353008&quot;&gt;&lt;/a&gt;reads the amount of data specified by &lt;code&gt;size&lt;/code&gt;, converts it according to the specified &lt;code&gt;format&lt;/code&gt; string, and returns it along with a &lt;code&gt;count&lt;/code&gt; of elements successfully read. &lt;code&gt;size&lt;/code&gt; is an argument that determines how much data is read. Valid options are:&lt;code&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;table border=&quot;2&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353011&quot;&gt;&lt;/a&gt;&lt;code&gt;n&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353013&quot;&gt;&lt;/a&gt;Read &lt;code&gt;n&lt;/code&gt; elements into a column vector.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353015&quot;&gt;&lt;/a&gt;&lt;code&gt;inf&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353017&quot;&gt;&lt;/a&gt;&lt;span style=&quot;font-family:sansserif;&quot;&gt;Read to the end of the file, resulting in a &lt;/span&gt;column vector containing the same number of elements as are in the file.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353019&quot;&gt;&lt;/a&gt;&lt;code&gt;[m,n]&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353021&quot;&gt;&lt;/a&gt;Read enough elements to fill an &lt;code&gt;m&lt;/code&gt;-by-&lt;code&gt;n&lt;/code&gt; matrix, filling the matrix in column order. &lt;code&gt;n&lt;/code&gt; can be &lt;code&gt;Inf&lt;/code&gt;, but not &lt;code&gt;m&lt;/code&gt;.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;353022&quot;&gt;&lt;/a&gt;&lt;code&gt;fscanf&lt;/code&gt; differs from its C language namesakes &lt;code&gt;scanf()&lt;/code&gt; and &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/fscanf.html&quot;&gt;fscanf&lt;/a&gt;&lt;/code&gt;&lt;code&gt;()&lt;/code&gt; in an important respect -- it is &lt;em&gt;vectorized&lt;/em&gt; in order to return a matrix argument. The &lt;code&gt;format&lt;/code&gt; string is cycled through the file until an end-of-file is reached or the amount of data specified by &lt;code&gt;size&lt;/code&gt; is read in.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353023&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;353024&quot;&gt;&lt;/a&gt;When MATLAB reads a specified file, it attempts to match the data in the file to the format string. If a match occurs, the data is written into the matrix in column order. If a partial match occurs, only the matching data is written to the matrix, and the read operation stops.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;353026&quot;&gt;&lt;/a&gt;The &lt;code&gt;format&lt;/code&gt; string consists of ordinary characters and/or conversion specifications. Conversion specifications indicate the type of data to be matched and involve the character &lt;code&gt;%&lt;/code&gt;, optional width fields, and c&lt;span style=&quot;font-family:sansserif;&quot;&gt;onversion characters, &lt;/span&gt;organized as shown below:&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/fileio3a.gif&quot; align=&quot;bottom&quot; /&gt;&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;353049&quot;&gt;&lt;/a&gt;Add one or more of these characters between the &lt;code&gt;%&lt;/code&gt; and the conversion character:&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;2&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;451990&quot;&gt;&lt;/a&gt;An asterisk (&lt;code&gt;*&lt;/code&gt;)&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;451992&quot;&gt;&lt;/a&gt;Skip over the matched value. If &lt;code&gt;%*d&lt;/code&gt;, then the value that matches &lt;code&gt;d&lt;/code&gt; is ignored and does not get stored.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;451994&quot;&gt;&lt;/a&gt;A digit string&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;451996&quot;&gt;&lt;/a&gt;Maximum field width. For example, &lt;code&gt;%10d&lt;/code&gt;.&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;451998&quot;&gt;&lt;/a&gt;A letter&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;452000&quot;&gt;&lt;/a&gt;The size of the receiving object; for example, &lt;code&gt;h&lt;/code&gt; for short as in &lt;code&gt;%hd&lt;/code&gt; for a short integer, or &lt;code&gt;l&lt;/code&gt; for long as in &lt;code&gt;%ld&lt;/code&gt; for a long integer &lt;code&gt;or&lt;/code&gt; &lt;code&gt;%lg&lt;/code&gt; for a double floating-point number.&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;353100&quot;&gt;&lt;/a&gt;Valid conversion characters are:&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;2&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt; &lt;caption&gt;&lt;br /&gt;&lt;/caption&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353065&quot;&gt;&lt;/a&gt;&lt;code&gt;%c&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353067&quot;&gt;&lt;/a&gt;Sequence of characters; number specified by field width&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353069&quot;&gt;&lt;/a&gt;&lt;code&gt;%d&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353071&quot;&gt;&lt;/a&gt;Decimal numbers&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353073&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;%e&lt;/code&gt;, &lt;code&gt;%f&lt;/code&gt;, &lt;code&gt;%g&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353075&quot;&gt;&lt;/a&gt;Floating-point numbers&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353077&quot;&gt;&lt;/a&gt;&lt;code&gt;%i&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353079&quot;&gt;&lt;/a&gt;Signed integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353081&quot;&gt;&lt;/a&gt;&lt;code&gt;%o&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353083&quot;&gt;&lt;/a&gt;Signed octal integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353085&quot;&gt;&lt;/a&gt;&lt;code&gt;&lt;code&gt;%s&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353087&quot;&gt;&lt;/a&gt;A series of non-white-space characters&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353089&quot;&gt;&lt;/a&gt;&lt;code&gt;%u&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353091&quot;&gt;&lt;/a&gt;Signed decimal integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353093&quot;&gt;&lt;/a&gt;&lt;code&gt;%x&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353095&quot;&gt;&lt;/a&gt;Signed hexadecimal integer&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a name=&quot;353097&quot;&gt;&lt;/a&gt;&lt;code&gt;[...]&lt;/code&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;a name=&quot;353099&quot;&gt;&lt;/a&gt;Sequence of characters (scanlist)&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;table&gt; &lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt; &lt;p&gt;&lt;a name=&quot;353101&quot;&gt;&lt;/a&gt;If &lt;code&gt;%s&lt;/code&gt; is used, an element read may use several MATLAB matrix elements, each holding one character. Use &lt;code&gt;%c&lt;/code&gt; to read space characters or &lt;code&gt;%s&lt;/code&gt; to skip all white space.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;353102&quot;&gt;&lt;/a&gt;Mixing character and numeric conversion specifications cause the resulting matrix to be numeric and any characters read to appear as their ASCII values, one character per MATLAB matrix element.&lt;/p&gt; &lt;p&gt;&lt;a name=&quot;353103&quot;&gt;&lt;/a&gt;For more information about format strings, refer to the &lt;code&gt;scanf()&lt;/code&gt; and &lt;code&gt;fscanf()&lt;/code&gt; routines in a C language reference manual.&lt;/p&gt; &lt;a name=&quot;examples&quot;&gt;&lt;/a&gt;&lt;a name=&quot;exmpl_sec&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;353104&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Examples&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;353105&quot;&gt;&lt;/a&gt;The example in &lt;code&gt;fprintf&lt;/code&gt; generates an ASCII text file called &lt;code&gt;exp.txt&lt;/code&gt; that looks like:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;353106&quot;&gt;&lt;/a&gt;0.00    1.00000000&lt;br /&gt;&lt;a name=&quot;353107&quot;&gt;&lt;/a&gt;0.10    1.10517092&lt;br /&gt;&lt;a name=&quot;353108&quot;&gt;&lt;/a&gt;...&lt;br /&gt;&lt;a name=&quot;353109&quot;&gt;&lt;/a&gt;1.00    2.71828183&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name=&quot;353110&quot;&gt;&lt;/a&gt;Read this ASCII file back into a two-column MATLAB matrix:&lt;/p&gt; &lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;353111&quot;&gt;&lt;/a&gt;fid = fopen(&#39;exp.txt&#39;);&lt;br /&gt;&lt;a name=&quot;353112&quot;&gt;&lt;/a&gt;a = fscanf(fid,&#39;%g %g&#39;&lt;code&gt;,&lt;/code&gt;[2 inf]) % It has two rows now.&lt;br /&gt;&lt;a name=&quot;353113&quot;&gt;&lt;/a&gt;a = a&#39;;&lt;br /&gt;&lt;a name=&quot;353114&quot;&gt;&lt;/a&gt;fclose(fid)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/1019796809905661218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/fscanf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/1019796809905661218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/1019796809905661218'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/fscanf.html' title='fscanf'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2734678215072839381.post-799133639277670614</id><published>2009-08-09T10:18:00.000-07:00</published><updated>2009-08-09T10:19:08.188-07:00</updated><title type='text'>frewind</title><content type='html'>Move the file position indicator to the beginning of an open file &lt;a name=&quot;syntax&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;352982&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Syntax&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul class=&quot;continued&quot;&gt;&lt;li class=&quot;continued&quot;&gt;&lt;pre&gt;&lt;a name=&quot;352983&quot;&gt;&lt;/a&gt;frewind(fid)&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a name=&quot;description&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;352984&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;352985&quot;&gt;&lt;/a&gt;&lt;code&gt;frewind(fid) &lt;/code&gt; &lt;a name=&quot;352988&quot;&gt;&lt;/a&gt;sets the file position indicator to the &lt;span style=&quot;font-family:sansserif;&quot;&gt;b&lt;/span&gt;eginning of the file specified by &lt;code&gt;fid&lt;/code&gt;, an integer file identifier obtained from &lt;code&gt;&lt;a href=&quot;http://www.physiol.ox.ac.uk/Computing/Online_Documentation/Matlab/techdoc/ref/fopen.html&quot;&gt;fopen&lt;/a&gt;&lt;/code&gt;.&lt;/p&gt; &lt;a name=&quot;remarks&quot;&gt;&lt;/a&gt;&lt;!-- H2 --&gt;&lt;a name=&quot;352990&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;font-size:+1;color:#990000;&quot;&gt;&lt;b&gt;Remarks&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;352991&quot;&gt;&lt;/a&gt;Rewinding a &lt;code&gt;fid&lt;/code&gt; associated with a tape device may not work even though &lt;code&gt;frewind&lt;/code&gt; does not generate an error message.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ideasdsp.blogspot.com/feeds/799133639277670614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/frewind.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/799133639277670614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2734678215072839381/posts/default/799133639277670614'/><link rel='alternate' type='text/html' href='http://ideasdsp.blogspot.com/2009/08/frewind.html' title='frewind'/><author><name>Blogspot</name><uri>http://www.blogger.com/profile/08922306495793559442</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>