正在加载图片...
Chapter 1. Introduction to MATLAB The variable r is a vector with two components, the symbolic forms of the two solutions. You can pick off the first component with phi r(1) which produces ph 1/2*5~(1/2)+1/2 TH ion can be converted to a numerical value in two different ways. It can to any number of digits using variable-precision arithmetic with the vpa(phi, 50) produces 50 digits 1.6180339887498948482045868343656381177203091798058 It can also be converted to double-precision floating point, which is the principal way that MATLAB represents numbers, with the double function. phi double(phi) 1.61803398874989 The aspect ratio equation is simple enough to have closed-form symbolic so- lutions. More complicated equations have to be solved approximately. The inline function is a quick way to convert character strings to objects that can be arguments to the MATLAB functions that operate on other functions f inline(1/x -(x-1)2) defines f(a)=1/-(a-1)and produces Inline function f(x)=1/x-(x-1) (Beginning with MATLAB 7, inline objects will be superceeded by a more powerful construction known as anonymous functions. Inline objects are still allowed in MATLAB 7, but anonymous functions are preferred because they produce more efficient code. The graph of f(a)over the interval 0 <a<4 shown in Figure 1.2 is obtained ezplot(f, 0,44 Chapter 1. Introduction to MATLAB The variable r is a vector with two components, the symbolic forms of the two solutions. You can pick off the first component with phi = r(1) which produces phi = 1/2*5^(1/2)+1/2 This expression can be converted to a numerical value in two different ways. It can be evaluated to any number of digits using variable-precision arithmetic with the vpa function. vpa(phi,50) produces 50 digits. 1.6180339887498948482045868343656381177203091798058 It can also be converted to double-precision floating point, which is the principal way that Matlab represents numbers, with the double function. phi = double(phi) produces phi = 1.61803398874989 The aspect ratio equation is simple enough to have closed-form symbolic so￾lutions. More complicated equations have to be solved approximately. The inline function is a quick way to convert character strings to objects that can be arguments to the Matlab functions that operate on other functions. f = inline(’1/x - (x-1)’); defines f(x) = 1/x − (x − 1) and produces f = Inline function: f(x) = 1/x - (x-1) (Beginning with Matlab 7, inline objects will be superceeded by a more powerful construction known as anonymous functions. Inline objects are still allowed in Matlab 7, but anonymous functions are preferred because they produce more efficient code.) The graph of f(x) over the interval 0 ≤ x ≤ 4 shown in Figure 1.2 is obtained with ezplot(f,0,4)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有