Moving a curve in one axis to ascertain area under the curve is zero
Show older comments
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!
Accepted Answer
More Answers (2)
Teja Muppirala
on 13 Sep 2017
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
on 13 Sep 2017
2 Comments
John D'Errico
on 13 Sep 2017
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
on 6 Jun 2019
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!