Info
此问题已关闭。 请重新打开它进行编辑或回答。
Simple for loop question.
2 次查看(过去 30 天)
显示 更早的评论
I am wanting to write a for loop for 2 differential equations.
For 0<x<5 dadb = (2*x)
For 5<x<10 dadb = (3*x)
How would I code this?
Cheers
3 个评论
Jan
2012-12-9
Are you sure that you mean a FOR-loop? Look at "doc for" and "help for", if this really matches your needs.
回答(1 个)
Rick Rosson
2012-12-9
编辑:Rick Rosson
2012-12-9
dx = 0.01;
x = (0:dx:10-dx)';
idx = (x < 5);
C = ...
D = ...
z = ( C + x.^2 / 2 ) .* idx + ( D + x.^3 / 3 ) .* ( 1 - idx ) ;
You will need to specify values for the constant C and D based on the initial value of z and the continuity condition at x = 5.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!