0
我設法提前解決了我遇到的問題,並且正在尋找關於我的外部for循環結構的建議。我的內循環正常工作。我想重複11次計算6次,每次迭代使用不同的高度(h值)。在J循環的迭代中,h增加到它的原始值+ 2 * h。 K循環中的POI取決於h並被定義,但爲了便於閱讀而省略。如有必要,可以使用完整腳本進行更新。 POI的定義是否應該在嵌套循環內?內循環工作 - 外循環不正確?
h = 0.5985;
GroundDistance = 18.75;
SouthAngle = 57;
TreeHeight = 14;
POI = TreeHeight-h;
BuildingElevationAng = atand(POI/GroundDistance);
a=0.265;
TreeLengthRHS = 15.89+a;
h = 0.5985;
X(1,1)=h;
for k = 2:6;
X(k) = X(k-1) + (X(1)*2);
end
for J = 1:6
h=h+(2*h);
for K = 1:11
TreeLengthTest(K) = TreeLengthRHS + (2*(K-1)*a);
TreeLengthLHS = 75 - TreeLengthTest(K);
AngleBx(K) = atand(TreeLengthLHS/GroundDistance);
AngleCx(K) = atand(TreeLengthTest(K)/GroundDistance); %wasTreeLengthRHS
DistanceAx(K) = GroundDistance/cosd(SouthAngle);
DistanceBx(K) = GroundDistance/cosd(AngleBx(K));
DistanceCx(K) = GroundDistance/cosd(AngleCx(K));
AltAngleA(K) = atand(POI/DistanceAx(K));
AltAngleB(K) = atand(POI/DistanceBx(K));
AltAngleC(K) = atand(POI/DistanceCx(K));
AzimuthA = 0;
AzimuthB = (-AngleBx)-SouthAngle;
AzimuthC = AngleCx-SouthAngle;
end
end
任何幫助,非常感謝。
除了H和j中的循環內使用,什麼是重複它的目的是什麼? – Daniel
爲了便於閱讀,我將腳本縮放了,但POI是一個用h定義的變量。我將更新該文章以包含完整的腳本。這可能更清晰。謝謝你的時間。 – loco
「它應該在嵌套循環內嗎?」它是什麼」?我不清楚你在問什麼 – darthbith