0
雖然我關注下面的代碼中的數組運算符,但我一直在得到一個矩陣維數的錯誤。由於我不願意嚴格執行矩陣運算,有人可以解釋尺寸/尺寸問題的起源嗎? 。函數句柄和數組運算符 - Matlab
由於使用
錯誤*矩陣尺寸必須同意
% integrand behaviour
[email protected](k) k .* exp(-k);
x=0.5;
al=1;
bet=0.89;
theta0=(1/al) .*atan(bet .*tan(pi*al/2));
c=exp(-(pi .* x) ./2 * bet);
c2=1 /(2.*abs(bet));
[email protected](theta) 2/pi .* ((pi/2 + bet.*theta)/cos(theta)) .* exp(1/bet .* (pi/2 +
bet.*theta)...
.* tan(theta));
[email protected](theta) c .* v1(theta);
[email protected](theta) f(g(theta)) ; % values of integrand
a=[-pi/2:0.2:pi/2]';
Y=y(a);
plot(a,Y)
這並不重要。我剛剛意識到問題的根源在於列向量'a'。實際上,代碼適用於任何標量(例如a = pi/6等),因此解決方案就是使它在矢量上工作,就我而言。 – owner
它確實很重要。事實上,你的'a'是一個16元素的列向量。我突出顯示的這條線將變成一個16x16的矩陣,這顯然是錯誤的。請記住,'/'是一個矩陣運算符,而'。/'是元素明智的。 –
非常感謝您的及時反饋,因爲我絕對錯過**。/ cos(theta)**。你是對的。乾杯 – owner