i have written this code i want to solve this heat equation for n vary from 0 to n(any value) for each value of x at each case from t= 0 to 10

1 次查看(过去 30 天)
syms l t n x pi alpha ;
a=input(('please enter alpha:'));
b=input(('please enter length:'));
c=input(('please enter number:'));
T(x,t)= 200/pi * ((-1)^(n+1))/n * sin (n*pi*x/l)*exp(-((n*pi/t)^2)*t);
symsum( T(x,t), n, 1, n);
this code is not running can any body tel me the right code

回答(1 个)

Matt Kindig
Matt Kindig 2013-4-22
Do you want to evaluate this numerically? Such that you have a value for T at each x and t. If so, your approach of using symsum is probably not the best way to go. Instead, I would do something like this:
a = input('please enter alpha:'); %note that this value isn't used anywhere
L = input('please enter length:');
N = input('please enter number:');
x = linspace(0, L, 50); %for example, 50 steps
t = linspace(0, 10, 50);
[X,T] = meshgrid(x,t); %make a big matrix
T = @(n) (200/pi).*(((-1).^(n+1))./n).*sin(n*pi*X/L).*exp(-((n*pi./T).^2).*T); %define T(x,t,n) function
%now you can find T at n=5, for example, using
T(5)

类别

Help CenterFile Exchange 中查找有关 Thermal Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by