Clear Filters
Clear Filters

How do I create a feedback to adjust variables based on error sum

1 view (last 30 days)
Hey, I'm working on a script where an error sum is determined by 2 divisors. At the moment I've played around a bit and found the divisors by trial and error to get a feel for the ratio, which means there's always some residue error. They currently sit at 3.63 and 1.36 with very little error, but there must be a perfect combination with no error.
From here my initial thought was to run multiple iterations of the script trying all combinations between 0 and 6, but I'm fairly certain matlab must have some clever built-in functions to do it smarter.
So essentially I would like a feedback of some sort to adjust div1 and div2 in a way that the error sum becomes 0.
Example code of how it looks now:
X_tar = 6;
Y_tar = 50;
div1 = 3.63;
div2 = 1.36;
... various equations being run in a for-loop using div1 and div2, storing each result in vectors X and Y
X_tot = sum(X);
Y_tot = sum(Y);
X_err = sqrt((X_tot - X_tar).^2);
Y_err = sqrt((Y_tot - Y_tar).^2);

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!