Plotting an integral function

5 次查看(过去 30 天)
I am trying to plot the followng equation. I am solving for stress.
My professor has told us that h' will be negative in the first and positive in the second. I used the following code, but my plot just shows a straight line. I think I should end up with a curve.
L=1.5;
h=.2;
s=.75*L;
tbar=1;
y=0;
for xbar=-1.5:.1:1.5
if xbar>-L & s>xbar
hprime=0.75;
else
hprime=-0.75;
end
fun= @(xbar) ((2*hprime)*((xbar-tbar)^3))/(((xbar-tbar)^2+y^2)^2);
Sxx1=integral(fun,-L,-s, 'ArrayValued',1);
Sxx2=integral(fun,s,L, 'ArrayValued',1);
Sxx=(((L-s)/h)*(Sxx1+Sxx2));
figure(1)
plot(Sxx,xbar,'.')
hold on
grid
title('Sxx vs xbar')
end

采纳的回答

Torsten
Torsten 2022-8-3
L=1.5;
h=.2;
s=.75*L;
tbar=1;
y=0;
icount = 0;
for xbar=-1.5:.1:1.5
icount = icount + 1;
if xbar>-L & s>xbar
hprime=0.75;
else
hprime=-0.75;
end
fun= @(tbar) ((2*hprime)*((xbar-tbar)^3))/(((xbar-tbar)^2+y^2)^2);
Sxx1=integral(fun,-L,-s, 'ArrayValued',1);
Sxx2=integral(fun,s,L, 'ArrayValued',1);
Sxx(icount)=(((L-s)/h)*(Sxx1+Sxx2));
%figure(1)
%plot(Sxx,xbar,'.')
%hold on
%grid
%title('Sxx vs xbar')
end
Warning: Minimum step size reached near x = -1.5. There may be a singularity, or the tolerances may be too tight for this problem.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 7.9e+00. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 5.3e+00. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.5e+01. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.5e+01. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 5.3e+00. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 8.0e+00. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Minimum step size reached near x = 1.5. There may be a singularity, or the tolerances may be too tight for this problem.
plot(-1.5:0.1:1.5,Sxx)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by