Plotting an integral function

5 vues (au cours des 30 derniers jours)
Kristine
Kristine le 3 Août 2022
Modifié(e) : Torsten le 3 Août 2022
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

Réponse acceptée

Torsten
Torsten le 3 Août 2022
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)

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by