zoukankan      html  css  js  c++  java
  • 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

     

     

     

  • 相关阅读:
    HDU 1312 Red and Black(经典DFS)
    POJ 1274 The Perfect Stall(二分图 && 匈牙利 && 最小点覆盖)
    POJ 3041 Asteroids(二分图 && 匈牙利算法 && 最小点覆盖)
    HDU 1016 素数环(dfs + 回溯)
    HDU 1035 Robot Motion(dfs + 模拟)
    vjudge Trailing Zeroes (III) (二分答案 && 数论)
    openjudge 和为给定数(二分答案)
    图的存储
    二分查找
    快速选择算法
  • 原文地址:https://www.cnblogs.com/zhangwenbiao/p/4312160.html
Copyright © 2011-2022 走看看