Plotting an integral function

조회 수: 5 (최근 30일)
Kristine
Kristine 2022년 8월 3일
편집: Torsten 2022년 8월 3일
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