# ListCountourPlot does not show any result [closed]

I was trying to show the heat conduction of Laplace equation problem.But the plot does not show properly

a = 2; b = 2; imax = 20; jmax = 20; k = 1;
dx = a/imax; dy = b/jmax;

For [i = 0, i < imax + 1, i++,
For[j = 0, j < jmax + 1, j++, T[i, j] = 0]]

For[i = 0, i <= imax, i++, T[i, 0] = 0; T[i, jmax] = 1];
For[j = 0, j <= jmax, j++, T[0, j] = 0; T[imax, j] = 0 ];
For[k = 1, k < 10, k++,
For[i = 1, i < imax, i++,
For[j = 1, j < jmax, j++,
T[i, j] = 0.25*(T[i + 1, j] + T[i - 1, j] + T[i, j + 1] + T[i, j - 1]);]]]


It seems there is something wrong in following code:

nn = Flatten[Table[{i*dx, i*dy, T[i, j]}, {i, 1, imax - 1}, {j, 1, jmax - 1}] // 1];
ListContourPlot[nn, PlotLegends -> Automatic, PlotRange -> All, Contours -> 20]


## closed as off-topic by m_goldberg, MarcoB, Carl Lange, José Antonio Díaz Navas, bbgodfreyFeb 18 at 21:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, MarcoB, Carl Lange, José Antonio Díaz Navas, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.

• What is the purpose of doing "//1" on nn ? I don't think it is doing whatever you were trying to do. – MinHsuan Peng Feb 13 at 17:28
• i was trying define the dimensions,maybe its wrong – matrix Feb 13 at 18:35

For-loops have lots of problems including that they are harder to follow than Do-loops. I will use Do. I will also reduce the size of max and jmax and give them different values to make my example result simpler but more general.

a = 2; b = 2;
imax = 10; jmax = 6;
dx = a/imax; dy = b/jmax;
k = 5;

Clear @ T;
Do[T[i, j] = 0, {i, 0, imax}, {j, 0, jmax}];
Do[T[i, jmax] = 1, {i, 0, jmax}];
Do[
Do[
T[i, j] = 0.25*(T[i + 1, j] + T[i - 1, j] + T[i, j + 1] + T[i, j - 1]),
{i, imax - 1}, {j, jmax - 1}],
k]


For the common situation of making xy-pairs or xyz-triples, the more convenient function Catenate has been defined to replace Flatten with a 2nd argument.

nn = Catenate @ Table[{i dx, j dy, T[i, j]}, {i, imax - 1}, {j, jmax - 1}];
ListContourPlot[nn, PlotLegends -> Automatic, PlotRange -> All, Contours -> 12]


### Update

Catenate can be replace by Flatten[#, 1]& in the above expression for nn, or you can rewrite it as
nn = Flatten[Table[{i dx, j dy, T[i, j]}, {i, imax - 1}, {j, jmax - 1}], 1];