Moving a curve in one axis to ascertain area under the curve is zero
이전 댓글 표시
Hi Folks,
Following is my function:
% where pd_def = defined constant which keeps changing for different situations
% b = pre-defined constant
% R = is calculated on the basis of pd_def
% x = x-axis variable which lets say assumes values in an interval [-b b]
% d_opt = variable which needs to take a value for defined parameters such that area under the
% curve 'y' is zero. This value once computed will be used to move the curve in y-direction to ensure that area under the
curve is zero.
R = b^2/(8*pd_def)+(pd_def/2);
y = R-sqrt(R^2-x^2) - (pd_def - d_opt);
I am having issues implementing this. Do I have to use optimisation toolbox to which I have no subscription. I would prefer an elegant solution without using the optimisation toolbox.
Please advice.
Cheers!
채택된 답변
추가 답변 (2개)
Teja Muppirala
2017년 9월 13일
Calculate the value of the integral when d_opt = 0, and then use that to set d_opt to cancel the integral out.
b = 0.1;
pd_def = 1;
R = b^2/(8*pd_def)+(pd_def/2);
y = @(x) R-sqrt(R^2-x.^2) - (pd_def); % First set d_opt = zero
val = integral(y,-b,b)
"val" contains the value of the integral when d_opt is zero.
Then set d_opt = -val/(2*b) , where 2*b is the length of the integral.
d_opt = -val/(2*b)
y = @(x) R-sqrt(R^2-x.^2) - (pd_def - d_opt);
areaUnderY = integral(y,-b,b)
This gives d_opt =
0.996654840715272
areaUnderY =
-4.838252194716564e-18
Basically zero.
Harsha K
2017년 9월 13일
댓글 수: 2
John D'Errico
2017년 9월 13일
You apparently did not bother to read the answer I spent a great deal of time writing. It explains exactly when you will have a problem.
Harsha K
2019년 6월 6일
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!