Looking to solve this integral with variable bounds
이전 댓글 표시
%variables
F = .00024; %kg
E = 10^6; %mPa
I = 6.1*10^-9; %kg m^2
L = .01; %m
%solve for Theta sub 0
func = @(OO) L/sqrt((E*I)/(2*F)) - integral(@(theta)1./sqrt(cos(OO)-cos(theta)),OO,pi/2);
g = fzero(func,0);
OS = fsolve(func,.5);
ideally wanted to use fzero but not sure how to do it, the like below, OS = ... kinda works but I keep getting pi/2 and not sure why. Im using this is the follwing equation:
aa = linspace(pi/2*.99, 0, 49);
aa=aa';
%shape of rod given
xi = sqrt((2*E*I)/F)*(sqrt(cos(OS))-sqrt(cos(OS)-cos(aa)));
and not getting the values i am hoping for. any help appreciated
댓글 수: 12
I am not certain what you want to do.
In any event, to understand the function, plot it —
F = .00024; %kg
E = 10^6; %mPa
I = 6.1*10^-9; %kg m^2
L = .01; %m
%solve for Theta sub 0
func = @(OO) L/sqrt((E*I)/(2*F)) - integral(@(theta)1./sqrt(cos(OO)-cos(theta)),OO,pi/2);
a = linspace(0, 2*pi, 250);
plotfunc = arrayfun(func, a);
figure
plot(a, real(plotfunc), a, imag(plotfunc))
grid
legend('Real','Imag', 'Location','best')
.
adam puchalski
2022년 7월 11일
Up to what you write, you only have to solve for OO once and then insert aa in the equation.
%variables
F = .00024; %kg
E = 10^6; %mPa
I = 6.1*10^-9; %kg m^2
L = .01; %m
%solve for Theta sub 0
func = @(OO) L/sqrt((E*I)/(2*F)) - integral(@(theta)1./sqrt(cos(OO)-cos(theta)),OO,pi/2);
OS = fsolve(func,.5)
aa = linspace(0,pi/2*.99, 49);
aa=aa';
%shape of rod given
xi = sqrt((2*E*I)/F)*(sqrt(cos(OS))-sqrt(cos(OS)-cos(aa)));
plot(aa,abs(xi))
Star Strider
2022년 7월 11일
The two functions you are using for that are root finding algorithms, and the integral function never crosses zero, except at approximately π, as can be seen in the plot.
Torsten
2022년 7월 11일
What do you mean by "it doesn't seem to work" ?
adam puchalski
2022년 7월 11일
The graph interpolates because the correct z(n) that makes the function zero is not hit.
I used more points for the graph (see above).
format long
F = .00024; %kg
E = 10^6; %mPa
I = 6.1*10^-9; %kg m^2
L = .01; %m
ep = 10^-8;
func = @(OO) L/sqrt((E*I)/(2*F)) - (2*(ep)^.5)/ (sin(OO))^.5 - integral(@(theta)1./sqrt(cos(OO)-cos(theta)),OO,pi/2);
%OS = fzero(func,.5);
OS = fsolve(func,0.5)
func(OS)
adam puchalski
2022년 7월 12일
It has nothing to do with "step size". At some stage, you reach the limits of floating-point arithmetics. You could try to set TolFun and/or TolX in the options for "fsolve" to a smaller value, but I think that a residual of 5e-9 should suffice for your purposes, doesn't it ?
Be happy that the integrator does not grump because your function has a singularity at "OO" (you try to evaluate 1/sqrt(cos(OO)-cos(OO)) which gives 1/0).
The series expansion around 0, e.g., seems to indicate that your integral does not exist because int(1/x,0,1) = Inf.
syms x
f = 1/sqrt(1-cos(x));
simplify(series(f,x,'ExpansionPoint',0,'order',10))
adam puchalski
2022년 7월 12일
Torsten
2022년 7월 12일
So in short:
Forget the complete discussion. Your problem is ill-posed.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


