箭 - 速度图Matlab

时间:2015-12-14 19:01:22

标签: matlab plot velocity ode

我正在使用Matlab箭来绘制这些微分方程:

  • dx = x。*(1-x-y);
  • dy = 2 * y。*(1-0.5 * y-3/2 * x);

我正在使用此代码:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Application.EnableEvents = False
    If Sh.Name = ActiveSheet.Name Then Call Wsh_MultipleSelection(Target)
    Application.EnableEvents = True
End Sub

Private Sub Wsh_MultipleSelection(ByVal rTrg As Range)
Const kTtl As String = "Selection Across Multiple Sheets"
Const kMsg As String = "You are trying to overwrite cells across multiple sheets." & vbLf & _
    "Press [Yes] if you want to continue and overwrite the selected cells" & vbLf & _
    "Press [No] if you want to overwrite selected cells in active sheet only" & vbLf & _
    "Press [Cancel] to undo last action."
Const kBtt As Long = vbApplicationModal + vbQuestion + vbYesNoCancel + vbDefaultButton3

Dim iResp As Integer
Dim vCllVal As Variant
Dim bWshCnt As Byte

    bWshCnt = ActiveWindow.SelectedSheets.Count
    If bWshCnt > 1 Then
        bWshCnt = -1 + bWshCnt
        iResp = MsgBox(kMsg, kBtt, kTtl)
        Select Case iResp
        Case vbYes
            Rem NO ACTION!
        Case vbNo:
            Rem Select Only Active Sheet
            vCllVal = rTrg.Cells(1).Value2
            Application.Undo
            rTrg.Value = vCllVal
        Case Else
            Rem Cancel
            Application.Undo
    End Select: End If
End Sub

我得到了这个fig。我不明白为什么我会得到小箭头,即使x和y稀疏! 我期待像this

这样的东西

我的问题:是否有办法(如果可以不使用外部包装)使箭头变大并着色?

提前致谢:)。

1 个答案:

答案 0 :(得分:1)

感谢Andras Deak,我们提出了这个解决方案:

[x,y] = meshgrid(0:0.2:2,0:0.2:2);
dx = x.*(1-x-y);
dy = 2*y.*(1-0.5*y-3/2*x);
% Normalization matrix
r = ( dx.^2 + dy.^2 ).^0.5;
figure
quiver(x,y,dx./r,dy./r)
相关问题