Solving nonlinear equations that include integrals with embedded variables

1 次查看(过去 30 天)
Hi there,
As mentioned in the subject, I have a fsolve-related question here.
This below is what I need to solve considering that theta_o is the only unknown:
I tried to use 'fsolve' to solve this, but no solution found.
clear;clc;close all
options = optimset('TolFun', 1e-20, 'Display', 'iter', 'MaxFunEvals', 1e10, 'MaxIter', 1e9, 'Algorithm', 'levenberg-marquardt');
T = 0.003;
H = 0.08;
I = H*T^3/12;
Px=10;
Py=1;
Mo=5;
P=Py;
n=Px/Py;
l=0.1;
E=69*10^10;
UnknownGuess = rand(1, 1);
[Unknowns, fval,exitflag] = fsolve('LD', UnknownGuess, options, I, P, n, Mo, l, E);
Theta = Unknowns(1);
%% LD function
function Eq = LD(Unknown, I, P, n, l, E, Mo)
Eq(1)=integral(@(x) 1./((2*P/E/I*(n*cos(x)-sin(x)-n*cos(Unknown(1))+sin(Unknown(1)))+Mo^2/E/E/I/I).^0.5),0,Unknown(1))-l;
end
%%%
No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
value of the function tolerance.
It‘s supposed to have a solution but I must made a mistake there.
Anyone can help me out?
Thanks so much,
Ke

采纳的回答

Dana
Dana 2020-9-8
Your call to fsolve:
fsolve('LD', UnknownGuess, options, I, P, n, Mo, l, E)
Your function syntax for LD:
Eq = LD(Unknown, I, P, n, l, E, Mo)
The last three parameters are in a different order. Change your call to fsolve to
fsolve('LD', UnknownGuess, options, I, P, n, l, E, Mo)
and I suspect that'll fix the problem.

更多回答(1 个)

Alan Stevens
Alan Stevens 2020-9-8
If Dana's suggestion doesn't work, the following non-symbolic approach does:
theta0init = pi/2;
theta0 = fzero(@intfn, theta0init);
disp([num2str(theta0) ' radians'])
disp([num2str(theta0*180/pi) ' degrees'])
function F = intfn(theta0)
T = 0.003;
H = 0.08;
I = H*T^3/12;
Px=10;
Py=1;
Mo=5;
P=Py;
n=Px/Py;
E=69*10^10;
l=0.1;
F = integral(@(theta) 1./(2*P/E/I*(n*cos(theta)-sin(theta)-n*cos(theta0)+sin(theta0))+Mo^2/E/E/I/I).^0.5 , 0 ,theta0) - l;
end

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by