Skip to content

Instantly share code, notes, and snippets.

@spestana
Created July 30, 2022 01:54
Show Gist options
  • Save spestana/8fcf9d78a36f6894b5cbe695ae5f40b1 to your computer and use it in GitHub Desktop.
Save spestana/8fcf9d78a36f6894b5cbe695ae5f40b1 to your computer and use it in GitHub Desktop.
clc; clear;
a0 = 0;
b0 = 0;
solution = lsqnonlin(@(x) difffun_a_b(x), [a0, b0]);
disp(solution);
function difference = difffun_a(a,b)
difference = (a*2 + b) - (1);
disp('diffun_a')
disp(difference);
end
function difference = difffun_a_b(x)
a0 = x(1);
b0 = x(2);
difference = lsqnonlin(@(x) difffun_a(x,b0), a0);
disp('diffun_a_b')
disp(difference);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment