How to get sinusodial behaviour from 2nd order ode using function handle?
Show older comments
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.

Answers (1)
Alan Stevens
on 28 May 2021
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
:
Categories
Find more on Heat and Mass Transfer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!