Is there a faster way than repeating this calculation manually?
Show older comments
I have a function file with 6 equations and 6 unknowns:
function F = TEST6lijn300(x)
F = [(x(1)^2 + x(2)^2 -753233.1);
((1447.5-x(3))^2 + (876.3-x(4))^2-966977.2);
((-72.4-x(5))^2 + (1723.1-x(6))^2-957129.6);
(x(5)^2 - 2*(x(5)*x(1)) + x(1)^2 + x(6)^2 - 2*(x(6)*x(2)) + x(2)^2 - 20449);
(x(3)^2 - 2*(x(3)*x(1)) + x(1)^2 + x(4)^2 - 2*(x(4)*x(2)) + x(2)^2 - 20449);
(x(3)^2 - 2*(x(3)*x(5)) + x(5)^2 + x(4)^2 - 2*(x(4)*x(6)) + x(6)^2 - 20449)];
end
I have managed to solve it using:
x0 = [5; 10; 5; 10; 5; 10]; % Make a starting guess at the solution options=optimset('Display','iter','MaxFunEvals',1000); % Option to display output [x,fval] = fsolve(@TEST6lijn300,x0,options) % Call solver
However I need to do this calculation hundreds of times, only changing the numbers 753233.1, 966977.2, and 957129.6. I have hundreds of sets of these three numbers which need to be pasted into the function file. So far, I have been doing it manually, but there must be a better way..
1 Comment
José-Luis
on 16 Jan 2013
What's wrong with passing the values to the function?
Accepted Answer
More Answers (1)
Categories
Find more on Spreadsheets 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!