tailieunhanh - matlab primer 7th edition phần 7

hoặc bất kỳ sự kết hợp, sử dụng các mảng tế bào của các giá trị biểu tượng hay chữ số. Việc thay thế thứ hai trả về một vector cột số có chứa các quyền hạn của 2 2-512. Mỗi mục trong mảng di động phải có cùng kích thước. Thay thế hành vi giống như thành phần trong tính toán. | fzero fa 1 fzero fb 3 Both functions can be easily solved with the Symbolic Toolbox. Note that solve correctly reports that 2 is a double root of x-2 A2. Try syms x s0lve x-2 A2 s s0lve x-2 A2-1e-12 fb s 1 fb s 2 The zeros of fb can be found numerically only if you guess close enough or if you provide two initial values of x for which fb differs in sign fzero fb 2 format long fzero fb 2 3 fzerofb 1 2 All of the functions used in the examples so far can be solved analytically. Here is one that cannot also plot the function so that you can see where it crosses the x-axis f @ x real airy x figure 1 clf ezplot f solve real airy x The first zero is easy to compute numerically s fzero f 0 hold on plot s f s ro 124 The fminbnd function finds a local minimum of a function given a fixed interval. This example looks for a minimum in the range -4 to 0. xmin fminbnd f -4 0 plot xmin f xmin ko To find a local maximum simply find the minimum of -f. g @ x -real airy x Xmax fminbnd g -5 -4 plot xmax f xmax ko Now find the zero between these two values of x s fzero f xmax xmin plot s f s ro The fminbnd function can only find minima of realvalued functions of a real scalar. To find a local minimum of a scalar function of a real vector x use fminsearch instead. It takes an initial guess for x rather than an interval. Ordinary differential equations The symbolic solution to the ordinary differential equation y t2y appears in Section . Here is the same ODE with a specific initial value of y 0 1 along with its symbolic solution. syms t y Y dsolve Dy tA2 y y 0 1 t Not all ODEs can be solved analytically so MATLAB provides a suite of numerical methods. The primary method for initial value problems is ode45. For an ODE of the form y f t y the basic usage is 125 tt yy ode45 @f tspan y0 where @f is a handle for a function yprime f t y that computes the derivative of y tspan is the time span to compute the solution a 2-element vector and y0 is the initial value of y. The variable t

TỪ KHÓA LIÊN QUAN