How can I give input to function?

1 回表示 (過去 30 日間)
RS
RS 2013 年 8 月 5 日
function u=heat(nx,hx,nt,ht,init,lowb,hib,K)
% Solves parabolic equ'n.
% e.g. heat flow equation.
% Example call: u=heat(nx,hx,nt,ht,init,lowb,hib,K)
% nx, hx are number and size of x panels
% nt, ht are number and size of t panels
% init is a row vector of nx+1 initial values of the function.
% lowb & hib are boundaries at low and hi values of x.
% Note that lowb and hib are scalar values.
% K is a constant in the parabolic equation.
alpha=K*ht/hx^2;
A=zeros(nx-1,nx-1); u=zeros(nt+1,nx+1);
u(:,1)=lowb*ones(nt+1,1);
u(:,nx+1)=hib*ones(nt+1,1);
u(1,:)=init;
A(1,1)=1+2*alpha; A(1,2)=-alpha;
for i=2:nx-2
A(i,i)=1+2*alpha;
A(i,i-1)=-alpha; A(i,i+1)=-alpha;
end
A(nx-1,nx-2)=-alpha; A(nx-1,nx-1)=1+2*alpha;
b(1,1)=init(2)+init(1)*alpha;
for i=2:nx-2, b(i,1)=init(i+1); end
b(nx-1,1)=init(nx)+init(nx+1)*alpha;
[L,U]=lu(A);
for j=2:nt+1
y=L\b; x=U\y;
u(j,2:nx)=x'; b=x;
b(1,1)=b(1,1)+lowb*alpha;
b(nx-1,1)=b(nx-1,1)+hib*alpha;
end
How can I use this function and what parameter I have to give for Input? Thanks

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 5 日
You should introduce the below constants
nx=
hx=
nt=
ht=
init=
lowb
hub=
k=
Then type
output=heat(nx,hx,nt,ht,init,lowb,hib,K)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeExternal Language Interfaces についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by