Plotting an integral function

5 visualizaciones (últimos 30 días)
Kristine
Kristine el 3 de Ag. de 2022
Editada: Torsten el 3 de Ag. de 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

Respuesta aceptada

Torsten
Torsten el 3 de Ag. de 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)

Más respuestas (0)

Categorías

Más información sobre Animation en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by