fsolve, time integration,
조회 수: 15 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Star Strider
2016년 7월 25일
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
Star Strider
2016년 7월 25일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!