How to get sinusodial behaviour from 2nd order ode using function handle?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuestas (1)
Alan Stevens
el 28 de Mayo de 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
:
0 comentarios
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!