码迷,mamicode.com
首页 > 其他好文 > 详细

Matlab symbolic computation memo

时间:2015-09-05 16:26:23      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:

Define a symbol

expr = sym((x=y)^2)

Define symbols

syms a b c d             % four symbols defined
A = [a b ; c d ]         % A is also a symbol
det(A)                   % symbolic computation of determinant

Factor and expand

factor(sym(x^2 - y^2))
expand(sym((x-y)^2)

Limits

limit(f, x, a)
limit(f, x, a, left)
limit(f, x, a, right)

Differentiation

diff(f, x, n)       % default value of n is 1

Integration

int(f, x)            % indefinite integral
int(f, x, a, b)     % integral over interval [a, b]

Fourier transform

fourier(fx, x, t)
ifourier(fw, t, x)

Laplace transform

laplace(fx, x, t)
ilaplace(fw, t, x)

Composition of functions

>> sym x;
>> f1 = sin(x);
>> f2 = cos(x);
>> compose(f1, f2)
 
ans =
 
sin(cos(x))

Solving differential equations

>> dsolve(D2y + omega^2 * y == 0,x)
 
ans =
 
C4*exp(omega*x*i) + C5*exp(-omega*x*i)

>> dsolve(‘Dy + y == 0‘, ‘y(0) == 3‘, ‘x‘) % ‘x‘ as independent variable
 
ans =
 
3*exp(-x)

Contour plotting

>> syms x y;
>> f = exp(-x^2 + -y^2);
>> ezcontour(f, [-1 1 -1 1])

技术分享

>> ezcontourf(f, [-1 1 -1 1])

技术分享

Mesh plotting

ezmesh(f, [-1 1 -1 1])

技术分享

>> ezmesh(@(x,y)(1+0.2*cos(y)).*cos(x), @(x,y)(1+0.2*cos(y)).*sin(x), @(x,y)0.2*sin(y), [0, 2*pi, 0, 2*pi])

技术分享

ezplot(f, ...)

ezplot3(x, y, z, [tmin tmax])
ezplot3(..., ‘animate‘)

ezpolar(f)
ezpolar(f, [theta_min theta_max])

ezsuf(f)
ezsurf(f, domain)
ezsurf(x, y, z, [smin smax tmin tmax])

Matlab symbolic computation memo

标签:

原文地址:http://www.cnblogs.com/ch3cooh/p/matlab_memo.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!