fsolve, time integration,
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hallo everybody,
I'm new here and i need help using fsolve! I would like to solve the following equation: All values are known except x
F = @(x) M*x + D*UTDOT + K*UT - Fext;
a = fsolve(F,0);
where
ALGAT = ((1-af)/(1-am))*x + (af/(1-am))*a - (am/(1-am))*alga;
UT = u + h*v + ((h^2)/2)*( (1-2*beta)*alga + 2*beta*ALGAT );
UTDOT = v +h*( (1-gamma)*alga + gamma*(ALGAT) );
if i write my problem the following way, i'm able to obtain a solution
F = @(x) M*x+D*(v +h*( (1-gamma)*alga + gamma*(((1-af)/(1-am))*x + ...
(af/(1-am))*a - (am/(1-am))*alga) ))...
+K*(u + h*v + ((h^2)/2)*( (1-2*beta)*alga + ...
2*beta*((1-af)/(1-am))*x + (af/(1-am))*a - (am/(1-am))*alga ))-Fext;
a = fsolve(F,0);
But i would like to solve the system in this form
F = @(x) M*x + D*UTDOT + K*UT - Fext; %M,D,K,Fext known values
a = fsolve(F,0);
How can handle UTDOT and UT to F ???
Thank you for your help!
0 Kommentare
Antworten (2)
Star Strider
am 25 Jul. 2016
I cannot run your code, but if ALGAT is a funciton of ‘x’, it and every term that uses it also need to be.
See if this works:
ALGAT = @(x) ((1-af)/(1-am)).*x + (af/(1-am))*a - (am/(1-am))*alga;
UT = @(x) u + h*v + ((h^2)/2)*( (1-2*beta)*alga + 2*beta.*ALGAT(x) );
UTDOT = @(x) v +h*( (1-gamma)*alga + gamma.*(ALGAT(x)) );
F = @(x) M*x + D.*UTDOT(x) + K.*UT(x) - Fext; %M,D,K,Fext known values
5 Kommentare
Star Strider
am 25 Jul. 2016
I can’t run your code, so executing only that loop:
F = @(x) x.^2 - 1;
x0 = 0;
h0 = (eps)^(1/3);
n = length(x0);
DF = zeros(n);
E = eye(n);
for i = 1:n
h = max(1,abs(x0(i)))*h0;
DF(:,i) = ( F(x0+h*E(:,i)) - F(x0-h*E(:,i)) )/(2*h);
end
it runs for me without error. If ‘x0’ has more than one element, it must be a column vector for your code to work, so adding this line early in your code will eliminate that problem:
x0 = x0(:);
That will create a column vector out of any vector of ‘x0’. That is not a problem here with only one parameter.
Siehe auch
Kategorien
Mehr zu Mathematics and Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!