a and b constant
Show older comments
HI, im new to matlab and was wondering how would you input a command to help me solve an unknown constant in an equation.
I have a bunch of x,y points,The equation would be x= a*y+b
Accepted Answer
More Answers (1)
% Only needed if x,y are not column vectors
x = reshape(x,[],1);
y = reshape(y,[],1);
% solve for a, b
x = [x, ones(numel(x),1)];
sol = y\x;
a = sol(1);
b = sol(2);
Categories
Find more on MATLAB 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!