Re: Defining a Function??
- To: mathgroup@smc.vnet.net
- Subject: [mg11477] Re: [mg11407] Defining a Function??
- From: Des Penny <penny@suu.edu>
- Date: Thu, 12 Mar 1998 01:35:11 -0500
- Organization: Southern Utah University
- References: <199803090113.UAA06520@smc.vnet.net.>
Hi Corey: The short answer to your problem is that you have 11 arguments in the definition of your function and you call it with only 10 arguments. When you are defining a function with this many arguments you might try to group them in logical subgroups using: OneDPlaneWall[{L_,rho_,k_,c_},{Tinfo_,TinfL_},ho_,hL_,{time_,T_,n_}] Or, you might also want to consider using Options. Consider how most Mathematica functions can be modified by using options. You can easily do this with your modules. See Roman Maeder's book for good examples. Another point: The ; before the final ] probably should not be there. Hope this helps. Des Penny Corey & Alicia Beaverson wrote: > Below is a program that I have written, with much help from the critique > on my last program...thanks everybody!. Anyway, if I define all of the > varibles as global, the program runs and outputs the results. I want to > set it up as a function though so I can use it for more than one case. > I am not sure what I am doing wrong here but for some reason it does > not seem to run, instead it just gives me the input back.....Thanks in > advance!!! > > In[29]:= > > OneDPlaneWall[L_,rho_,k_,c_,Tinfo_,TinfL_,ho_,hL_,time_,T_,n_]:= > Module[{ alpha, deltax, Bio, BiL, foo, foi,foL, deltat, fo}, > alpha=k/(rho*c); > deltax=L/(n-1); > Bio=(ho*deltax)/k; > BiL=(hL*deltax)/k; > foo=1/(2(1+Bio)); > foi= 0.5; > foL=1/(2(1+BiL)); > fo=Min[foo,foi,foL]; > deltat=(fo(deltax)^2)/alpha; > T=Table[T, {n}]; > While[ Min[T]>0, > time=time+deltat; > T[[1]]=((1-2*fo-2*Bio*fo)T[[1]] +fo*2(T[[2]]+Bio*Tinfo)); > T[[Range[2,n-1]]]= > Table[Int=((1-2*fo)T[[i]]+fo(T[[i-1]]+T[[i+1]])), {i,2,n-1}]; > T[[n]]=((1-2*fo-2*BiL*fo)T[[n]]+fo*2(T[[n-1]]+BiL*TinfL))];] > T > time > > Out[30]= > Table[T,{n}] > Out[31]= > time > In[32]:= > OneDPlaneWall[0.25,1860,0.72,17,-6,100,60,0,17,11] Out[32]= > OneDPlaneWall[0.25,1860,0.72,17,-6,100,60,0,17,11]
- References:
- Defining a Function??
- From: Corey & Alicia Beaverson <cbeavers@utk.edu>
- Defining a Function??