fsolve, time integration,

11 visualizaciones (últimos 30 días)
Stefan Holzinger
Stefan Holzinger el 25 de Jul. de 2016
Respondida: Stefan Holzinger el 2 de Ag. de 2016
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!

Respuestas (2)

Star Strider
Star Strider el 25 de Jul. de 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 comentarios
Star Strider
Star Strider el 25 de Jul. de 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.
Stefan Holzinger
Stefan Holzinger el 1 de Ag. de 2016
Hey Star Strider, thank you for your help. Your solution works. :)
In the meanwhile another problem appeared. I tried to solve it but until now i failed. Maybe you have an idea how to do it. Heres the Problem.
I would like to solve the equation F for x :
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)) );
[M,D,K] = fun(UT(x),UTDOT(x),t);
F = @(x) M(UT(x))*x + D(UT(x),UTDOT(x))*UTDOT(x) + K*UT(x) = 0
x0 = zeros(...)
solu = newton(F,x0)
The Problem is now: M,D,K are defined within the function fun and they are depend on UT and UTDOT.
My question is: How can i tell matlab within F that M,D and K are dependent of UT(x) and UTDOT(x)??

Iniciar sesión para comentar.


Stefan Holzinger
Stefan Holzinger el 2 de Ag. de 2016
Hallo Star Strider,
could you maybe take a look a this Problem of mine? Of interest would be my last post in this question. Thank you for your help!
https://de.mathworks.com/matlabcentral/answers/298154-functions-retuning-functions-fsolve
The key words to sind the side would be: functions retuning functions, fsolve

Categorías

Más información sobre Mathematics and Optimization en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by