1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Graphing Problem in Mathematica

  1. Dec 15, 2012 #1
    1. The problem statement, all variables and given/known data
    I would like to graph the following program.


    2. Relevant equations
    L = 1.0; \[Kappa] = 1.; Num = 80; \[CapitalDelta]z = L/Num;
    td = (\[CapitalDelta]z*\[CapitalDelta]z)/(2*\[Kappa]); \
    \[CapitalDelta]t = 1.01*td; r = (\[CapitalDelta]t/(2*td));

    Temp[0] = 10.; Temp[Num] = 10.;
    Do[Temp = 10., {s, 1, (Num/2 - 6)}]; Do[
    Temp = 50., {s, (Num/2 - 5), (Num/2 + 5)}]; Do[
    Temp = 10., {s, (Num/2 + 6), (Num - 1)}]
    data = Table[{ss*\[CapitalDelta]z, Temp[ss]}, {ss, 0, Num}];
    ListPlot[data, PlotRange -> {-5, 55}, PlotStyle -> PointSize[0.02],
    AxesLabel -> {"z", "T[z]"}, PlotLabel -> Initial Temp];

    cycle = 0;
    Do[Do[NewTemp =
    Temp + r*(Temp[s - 1] - 2*Temp + Temp[s + 1]),
    {s, 1, (Num - 1)}];
    Do[Temp[ss] = NewTemp[ss], {ss, 1, Num - 1}]; cycle = cycle + 1;
    If[cycle >= 1, t = n*\[CapitalDelta]t;
    Print["time=", t, " iterations=", n];
    data = Table[{sss*\[CapitalDelta]z, Temp[sss]}, {sss, 0, Num}];
    ListPlot[data, PlotRange -> {-5, 55}, AxesLabel -> {"z", "T[z]"},
    PlotStyle -> PointSize[0.02]]; cycle = 0],
    {n, 1, 200}] cycle = 0;
    3. The attempt at a solution
    Mathematica gives me the time iterations, but no graphs. I don't know what to do; I want the graphs to show up.
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted