finding optimum solution
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone,
I would apprechiate help with the following matter I have the following vectors A,D,B,C,E (each size 50,1) and calculate T=-A.*((B+x)-C)+D.*E; The goal is to find constant x so that sum(T)==0. I tried fminsearch, but didn't figure out how to make it work. I would be greatful for any help. Thanks.
2 commentaires
Réponse acceptée
Andrew Newell
le 30 Mar 2011
I'm going to rewrite your problem in vector notation. Suppose the positions are given by vectors r_i, i=1..50, and the forces by F_i, i=1..50. The coordinates of the center are r_c. Then the torque on the system is sum_i (r_i-r_c)xF_i, where the x refers to the cross product. This can be separated into two terms: sum_i (r_i x F_i) - r_c x sum_i F_i. So you need a torque function
function T = torque(r,ri,Fi)
% Add a z component (all zeros) to allow use of CROSS.
r = [r 0];
ri = [ri zeros(length(ri),1)];
Fi = [Fi zeros(length(Fi),1)];
F = sum(Fi);
T = sum(cross(ri,Fi,2))-cross(r,F,2);
T = T(3); % The torque is only nonzero perpendicular to the plane.
To run it, save the function in a file torque.m and use these commands:
ri = [B E];
Fi = [A D];
f = @(x) torque(x,ri,Fi); % create a function f(x)
r0 = [0 0]; % initial guess for the center
rc = fsolve(f,r0)
Plus de réponses (1)
Andrew Newell
le 29 Mar 2011
As defined, your problem has an infinite number of solutions. You can expand your expression to get
T=-A.*x+D.*E-A.*B+A.*C;
Thus, for any vector T,
x = (D.*E-A.*B+A.*C-T)./A;
so you could choose any components for T so that sum(T)==0 and solve this equation.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!