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 Center および File ExchangeAnimation についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by