MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayMATLAB Central > MATLAB Newsreader > CrankNicolson method 

I'm trying to follow an example in a MATLab textbook. It has the following code which I have simply repeated. After the code it says: "the following MATLab function heat_crank.m finds the solution of the heat equation using the CrankNicolson method. Inputs are function f; boundary condition c1, c2; endpoint L; maximum time T; step sizes h and k; constant alpha. The input function f(x) should be defined as an mfile." 
On 22/08/10 7:21 AM, Scott wrote: 
Ok, so I tried that but it hasn't worked because I haven't defined values for c1,c2 etc etc. In which file do I do this?? 
On 22/08/10 10:37 AM, Scott wrote: 
On Aug 22, 11:37 am, "Scott " <boofheadf...@hotmail.com> wrote: 
Hi, instead of putting the function for f in a separate mfile I tried putting it in the main file. I also tried to define c1,c2,L etc values in the main function. My script is below. When I try to run the script it says this: 
On 22/08/10 8:00 PM, Scott wrote: 
Clearly didn't understand it, 
On 22/08/10 9:24 PM, Scott wrote: 
> function A_Blatant_Hint 
On 22/08/10 9:58 PM, Scott wrote: 
Scott 
I took away the header function heat_crank and made a new mfile called f_x with the function in it and ran heat_crank and it appears to have worked. I have to show how the temperature (zaxis) appears over time and length so I want to make a mesh grid of the values of temperature over the time 0<t<0.5 and length 0<x<2. I can't get this to work. I'm not sure if all the temperature values have been calculated or if it's just calculated temperature for a certain x or t value... 
On 22/08/10 11:52 PM, Scott wrote: 
I've done a complete rewrite and I have this code. It runs fine except it is not quite calculating the correct values. I think there is something wrong with my code for uu or somewhere below that but i could be wrong. 
The linear system of equations for the CNmethod reads 
On Aug 23, 2:52 pm, "Scott " <boofheadf...@hotmail.com> wrote: 
No tags are associated with this thread.
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.