이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Looking to solve this integral with variable bounds
조회 수: 2 (최근 30일)
이전 댓글 표시
adam puchalski
2022년 7월 11일
%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
Star Strider
2022년 7월 11일
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일
essentially I would like to solve for "OO" in "func" and then use that valuie of OOin my equation for xi.
Torsten
2022년 7월 11일
편집: Torsten
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)
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
OS = 1.5708
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.
adam puchalski
2022년 7월 11일
편집: Torsten
2022년 7월 11일
ok so i edited it and ff1 should cross zero now but still does not seem to work
format long
F = .00024; %kg
E = 10^6; %mPa
I = 6.1*10^-9; %kg m^2
L = .01; %m
ep = 10^-8;
z(1) = 0;
for n = 2:10001
z(n) = z(n-1) + ((pi/2)/10000);
ff1(n) = L/sqrt((E*I)/(2*F)) - (2*(ep)^.5)/ (sin(z(n)))^.5 - integral(@(theta) 1./sqrt(cos(z(n))-cos(theta)),z(n)+ep,pi/2);
end
Warning: Minimum step size reached near x = 1.5708. There may be a singularity, or the tolerances may be too tight for this problem.
%figure(5)
plot(z,real(ff1))

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)
Equation solved, inaccuracy possible.
The vector of function values is near zero, as measured by the value
of the function tolerance. However, the last step was ineffective.
OS =
1.570794630102631
L/sqrt((E*I)/(2*F))
ans =
0.002805147493273
pi/2
ans =
1.570796326794897
adam puchalski
2022년 7월 11일
the value for OS is either rounded, or inaccurate. Zooming in on the vlaue in the plot, the graph crosses at a value smaller than 1.5708
Torsten
2022년 7월 11일
편집: Torsten
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)
Equation solved, inaccuracy possible.
The vector of function values is near zero, as measured by the value
of the function tolerance. However, the last step was ineffective.
OS =
1.570794630102631
func(OS)
ans =
4.675807340707300e-09
adam puchalski
2022년 7월 12일
I see, that makes sense! when you fun
func(OS)
thats still not zero. is that due to the step size? can i make the step size even smaller?
Torsten
2022년 7월 12일
편집: Torsten
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))
ans =
답변 (0개)
참고 항목
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)

