Creating a guess and check loop
显示 更早的评论
Hello everyone. I am wanting to create function in matlab that will do the following:
From a given rectangular cross section (inputs being height and width) I want matlab to first guess a given distance that is a fraction of the height.
After that I want matlab to execute 5 simple addition/multiplication commands. The 6th command will use data from the previous 5 steps and compile an equation. (T=X+Y, these variables found in previous 5 steps) & if the equation is true I want matlab to go on and compute a few more things. BUT if T>X+Y I want matlab to go back and select a larger fraction of the height, if T<X+Y I want matlab to go back and select a smaller fraction of h. After it selects this new value I want matlab to continue that same loop until the equation T=X+Y is satisfied.
Any help or pointers are appreciated. I would think that I put a "while loop" in there somewhere? but not sure. I am good with if and if else statements too if you think I should utilize those to make this most efficient. Thanks everyone in advance!
-Will
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
