How do you create a loop to find a coefficient value to which one of the variables in the function changes with every cycle
古いコメントを表示
For example:
The change in weight (dW) of an aircraft due to fuel consumption is shown below:
dW=(-SFC/N)*sqrt((2*W^3)/(p*S))*(1/((Cl^1.5)/Cd))*dt
With 'W' being the total weight of the aircraft and current fuel load, 'dt' being the change in time of the aircraft and the rest of the coefficients being constant. For a given time period of 100,000 seconds, how would the loop be generated? As the 'W' variable would change with every cycle, resulting in a different dW in every cycle ad so on. I believe the following should be involved but I'm not sure how, any help would be greatly appreciated.
dt=0:100:100000
W=W+dW
dW=(-SFC/N)*sqrt((2*W^3)/(p*S))*(1/((Cl^1.5)/Cd))*dt
Thanks alot James
1 件のコメント
Oleg Komarov
2011 年 2 月 3 日
You don't need a loop. Plug in all the values...and whenever you need an element by element operation between SAME size vectors, use the .() operators (ex: .*, ./).
Or post all the relevant values for the vars involved and the full error message if you don't succeed in the implementation.
採用された回答
その他の回答 (1 件)
Walter Roberson
2011 年 2 月 3 日
0 投票
The code shown is independent of the time if the time-step is constant. The code can then be rewritten as a differential equation. In Maple notation, it would be:
dsolve({W(0) = W0, diff(W(t), t) = -SFC*sqrt(2*W(t)^3/(p*S))*Cd/(N*Cl^1.5)})
where W0 is the initial weight.
Maple returns the following solution:
W(t) = RootOf(2*t*SFC*Cd+N*sqrt(2)*Cl^(3/2)*(Int(1/sqrt(_a^3/(p*S)), _a = _b .. _Z))-N*sqrt(2)*Cl^(3/2)*(Int(1/sqrt(_a^3/(p*S)), _a = _b .. W0)))
I must admit that I have no idea what the introduced variable _b is supposed to mean. If I ask Maple to combine the parts, I get
W(t) = RootOf(Int(N*sqrt(2)*Cl^(3/2)/sqrt(_a^3/(p*S)), _a = W0 .. _Z)+2*t*SFC*Cd)
which basically means that W(t) is the value of the variable _Z that causes the expression inside the RootOf() to evaluate to 0. This will be a decreasing value as t increases.
The Int() part can be evaluated to a closed form under some circumstances, depending upon the signs of the values involved. If the known constraints on the constants allow for it, then a ratio of two polynomials results, and equating to -2*t*SFC*Cd and solving for _Z gives an exact ratio-of-polynomials form and thus an exact form for W(t) without needing simulation.
1 件のコメント
David Young
2011 年 2 月 8 日
An instructive exercise is to compare the results from the Euler method numerical integration with the results from the analytical solution, and particularly observing how changes to delta-t affect the errors.
カテゴリ
ヘルプ センター および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!