How to get sinusodial behaviour from 2nd order ode using function handle?

조회 수: 11 (최근 30일)
Henry B.
Henry B. 2021년 5월 28일
답변: Alan Stevens 2021년 5월 28일
function[dtheta] = FiniteConduct(x,t,alph,L)
n=[1:10]
dtfh= @(t) 1-x./L -2 ./pi.*sum(1 ./n .*exp(-alph.*t.*((n.*pi/L).^2)).*sin(n.*pi.*x./L));
dtheta = dtfh(t(1));
for (k=1:numel(t)-1)
for (n = 1:10)
for (x = [0:.01:.1])
x = x+1;
if(x<L)
n=n+1;
dtheta(k+1) = dtheta(k) + dtfh(t(k+1))
else
x = L;
end
end
end
end
end
There seems to be something wrong with my function handle and the way I have implemented the sigma notation for sum? im trying to use convert this equation below into a function handle.

답변 (1개)

Alan Stevens
Alan Stevens 2021년 5월 28일
You coud try implementing the function along these lines (obviously, you will need to use your own values for alpha etc):
alpha = 0.1;
L = 1;
t = 0.1;
x = 0:0.01:1;
for i = 1:numel(x)
theta(i) = dtfh(x(i),t,alpha,L);
end
plot(x,theta)
function theta = dtfh(x,t,alpha,L)
S = 0;
Sold = 100;
n = 0;
while abs(S-Sold)>1e-8
Sold = S;
n = n+1;
S = 1/n*exp(-alpha*t*(n*pi/L)^2)*sin(n*pi*x/L) + S;
end
theta = 1 - x/L - 2/pi*S;
end
:

카테고리

Help CenterFile Exchange에서 Heat and Mass Transfer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by