Variable in function as well as integral boundary
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have an integral I want to compute and plot for different angles theta. 0-90 degrees.
For every angle I want to compute the integral of the function from 0 up to the angle theta.
theta = 1:90;
A = 0.4*10^-19;
R = 4215 * theta.^(-1.35)*10^-9;
D_0 = 0.3;
D_c = R.*(1-cosd(theta));
D = (D_0 + D_c)*10^-9;
b = 0.2*10^-6;
Fun = @(theta) (A ./ (6 .* pi .* (D_0 + R .* ( 1-cosd(theta))).^3)) .* b .* R;
F_vdW1 = integral(Fun, 0, theta);
Can someone please help with what I am doing wrong?
Thanks
0 个评论
采纳的回答
Torsten
2022-10-22
编辑:Torsten
2022-10-22
Is it this what you want ?
If not, please clarify how the theta in the integrand and in the upper bound of the integral should be interpreted. Mathematically, your notation to use the same name for both is wrong.
theta = 1:90;
A = 0.4*10^-19;
R = 4215 * theta.^(-1.35)*10^-9;
D_0 = 0.3;
D_c = R.*(1-cosd(theta));
D = (D_0 + D_c)*10^-9;
b = 0.2*10^-6;
Fun = (A ./ (6 .* pi .* (D_0 + R .* ( 1-cosd(theta))).^3)) .* b .* R;
F_vdW1 = cumtrapz(theta,Fun);
plot(theta,F_vdW1)
3 个评论
Torsten
2022-10-22
编辑:Torsten
2022-10-22
Are you sure that "phi" should enter the equation for R in degrees and not in radians ?
And according to your graphics, only the 6 and not the complete expression 6*pi*[D0+R*(1-cos(phi))]^3 would appear in the denominator of the integrand.
A = 0.4*10^-19;
R = @(phi) 4215 * phi.^(-1.35)*10^-9;
D_0 = 0.3;
D_c = @(phi) R(phi).*(1-cosd(phi));
D = @(phi) (D_0 + D_c(phi))*10^-9;
b = 0.2*10^-6;
Fun = @(phi)(A ./ (6 .* pi .* (D_0 + R(phi) .* ( 1-cosd(phi))).^3)) .* b .* R(phi);
theta = 1:360;
F_vdW1 = arrayfun(@(theta)integral(Fun,0,theta),theta)
plot(theta,F_vdW1)
更多回答(1 个)
Bruno Luong
2022-10-22
编辑:Bruno Luong
2022-10-22
I have no idea if the code correspondons to the formula; I just modify your code to make it work on array
theta = 1:90;
A = 0.4*10^-19;
R = @(theta) 4215 * theta.^(-1.35)*10^-9;
D_0 = 0.3;
D_c = @(theta) R.*(1-cosd(theta));
b = 0.2*10^-6;
Fun = @(theta) (A ./ (6 .* pi .* (D_0 + R(theta) .* ( 1-cosd(theta))).^3)) .* b .* R(theta);
F_vdW1 = arrayfun(@(onetheta) integral(Fun, 0, onetheta), theta)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!