Creating a guess and check loop
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!