我需要繪製一小塊與其平衡態有小偏差的點。使用quiver
它應該是這樣的:僅繪製顫抖的終點
現在我要繪製只是位於箭頭提示標誌。怎麼做?
輸入數據是U和V的偏差(關於笛卡爾軸),得到了X,Y矢量起點的座標是沒有問題的。
我需要繪製一小塊與其平衡態有小偏差的點。使用quiver
它應該是這樣的:僅繪製顫抖的終點
現在我要繪製只是位於箭頭提示標誌。怎麼做?
輸入數據是U和V的偏差(關於笛卡爾軸),得到了X,Y矢量起點的座標是沒有問題的。
你不能簡單地使用像plot(X+U, Y+V, 'o')
因爲quiver
適用的自動計算規模到U
和V
讓所有的箭適合很好的身影。您需要包含該比例。
展望quiver
的代碼複製,計算的是大規模的一部分,你可以進行如下操作:
%// Example data
x = rand(1,20);
y = rand(1,20);
u = rand(1,20);
v = rand(1,20);
%// Taken from "quiver.m". Computes autoscale
if min(size(x))==1, n=sqrt(numel(x)); m=n; else [m,n]=size(x); end
delx = diff([min(x(:)) max(x(:))])/n;
dely = diff([min(y(:)) max(y(:))])/m;
del = delx.^2 + dely.^2;
if del>0
len = sqrt((u.^2 + v.^2)/del);
maxlen = max(len(:));
else
maxlen = 0;
end
if maxlen>0
autoscale = 0.9/maxlen;
else
autoscale = 0.9;
end
%// quiver plot
quiver(x, y, u, v)
hold on
%// plot marker at arrow tips, including computed autoscale
plot(x+autoscale*u, y+autoscale*v, 'o')
如果指定比例參數到quiver
,這樣的說法是一個因素相乘內部計算的比例。所以,你必須包括在plot
還有:
%// quiver plot including manual scale factor
quiver(x, y, u, v, .5)
hold on
%// plot marker at arrow tips, including computed autoscale and manual scale
plot(x+.5*autoscale*u, y+.5*autoscale*v, 'o')
不錯!如果我有Matlab,我會搶劫你這個答案:P Good one –
@AnderBiguri謝謝:-) –
如果你知道X,點Y的起源和U,V偏差,那麼你知道終點,不要你呢?然後使用'plot(x,y,'。'')來繪製它們' –
@AnderBiguri但是'顫抖'對這些'U','V'應用了一個比例尺。你必須包含那個尺度,這個尺度並不是先驗知識 –
@LuisMendo,但是顫抖有一個「尺度」輸入選項! –