solving a multivariate equation (4 equations, 4 variables) for n rows data using loop
Show older comments
I wrote this code to solve a multivariate equation (4 equations, 4 variables) while aprim0,bprim0, xmid, and ymid are available
for i = 1:n
eqn1 = yup(i,1) - (aprim0(i,1)*xup(i,1)) - bprim0(i,1) == 0;
eqn2 = ydown(i,1) - (aprim0(i,1)*xdown(i,1)) - bprim0(i,1) == 0;
eqn3 = sqrt((xup(i,1) - xmid(i,1))^2 + (yup(i,1) - ymid(i,1))^2) - 0.008 == 0;
eqn4 = sqrt((xdown(i,1) - xmid(i,1))^2 + (ydown(i,1) - ymid(i,1))^2) - 0.008 == 0;
eqns = [eqn1, eqn2, eqn3, eqn4];
vars=[xup(i,1), yup(i,1), xdown(i,1), ydown(i,1)];
sol = solve('eqns', 'vars');
end
but it did not work in solve function, where is my mistake?
Accepted Answer
More Answers (0)
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!