該代碼旨在計算具有疊加原理的光束的偏轉,其中對於光束的每個給定位置,計算所有單獨的力的影響,然後相加在一起。循環播放不同尺寸的矢量
function deflection = beamSuperposition(positions, beamLength,loadPositions, loadForces, beamSupport)
%If several loads are applied, calculate each one individually and end with sum
x = positions;
l = beamLength;
a = loadPositions;
W = loadForces;
E = 200*10^9;
I = 0.001;
%For every position(x) element calculate the expression for all
%loadPositions(a) and their respective loadForce(W)
%Make sure a and W are of same size
%Make sure neither x or a ever surpass l
%Go trhough each element of x
for i = 1:length(x)
%For beamSupport = 1 only
while beamSupport == 1
%Go through each element of 'a' and calculate the deflection
for n = 1:length(a)
%There are two different equations to calculating the deflection depending on the position of the loadForce compared to the position of interest
while true
if x(i) < a(n)
y = (W(n)*(l-a(n))*x(i))*(l^2-x(i)^2-(l-a(n))^2)/(6*E*I*l);
end
if x(i) >= a(i)
y = (W(n)*a(n)*(l-x(i)))*(l^2-(l-x(i))^2-a(n)^2)/(6*E*I*l);
end
break
end
end
break
end
%Sum the values for each y element?!?
deflection = y
end
我該如何按預期做這項工作?輸出應該是一個矢量y
,其大小與x
相同,每個值的總和偏差爲x
。
使用中;
beamSuperposition([1,2,5],10,[6,5,3],[10,15,20],1)
就回去了,如果deflection = y
不supressed,
deflection =
5.8333e-07
deflection =
1.0967e-06
deflection =
1.6500e-06
ans =
1.6500e-06
但首先應該只
可能的錯誤線路28上,應讀'如果x(I)> = A(N)'?不知道爲什麼這是在一段時間「循環」,看起來只會評估一次。 – Steve
你能用短行顯示它的用法來編輯你的問題嗎? – Steve
也許你想保存輸出到'y(i)' – Steve