MATLAB学习拾遗

1.坐标轴修饰

axis equal;axis([0,6,0,6])

 

不修饰则为默认网格

grid on

 

2.不太漂亮的pretty命令

3. Laplace变换

                                                                                                                               syms t s a b

                                                                                                                                 f1=exp(-a*t)*sin(b*t) 

F1=laplace(f1,t,s)

4. 逻辑计算

>> A=[-2,-1,0,0,1,2,3]

A =

-2 -1 0 0 1 2 3

>> L1=~(A>1)

L1 =

1 1 1 1 1 0 0

>> L2=(A>0)&(A<2)

L2 =

0 0 0 0 1 0 0

5. Legend修饰

>> t=(0:0.02:2)*pi;
x=sin(t);y=cos(t);z=cos(2*t);
plot3(x,y,z,'b-',x,y,z,'bd')
view([-82,58]),box on
xlabel('x'),ylabel('y'),zlabel('z')
legend(' 链',' 宝石','Location','best')

6. 函数取值

Replace variables x and y with these 2-by-2 matrices. subs expand the scalars x and y to arrays of the same size and performs substitutions:

syms x y
subs(x*y, {x, y}, {[0 1; -1 0], [1 -1; -2 1]})

 

ans =
0 -1
2 0

 

Note that these substitutions are elementwise:
[0 1; -1 0].*[1 -1; -2 1]

 

ans =
0 -1
2 0

 

subs(x+y, {x, y}, {[0 1; -1 0], [1 -1; -2 1]})

 

ans =

1 0
-3 1

注意

Assign the expression x + y to f:


syms x y


f = x + y;

Replace y in this expression with the value 1. Here f itself does not change:


subs(f, y, 1); f

f =
x + y

To replace the value of f with the new expression, assign the result returned be subs to f:
f = subs(f, y, 1);

f

f =

x + 1

 

 

 

posted @ 2015-03-03 23:26  张文彪  阅读(216)  评论(0编辑  收藏  举报