# Question:error: adding new index to table is overwriting a different index

## Question:error: adding new index to table is overwriting a different index

Maple
This is a portion of my first Maple program. I included the part that had the relevant code and output of what is going wrong. The problem I am having is in the PlotTable I create. It is a table with specifically defined indices, which gets added to each time through a loop. What each indices refers to is a table of lists, representing an x,y coord pair. The first time an index is added is corrects puts the data. The second time you can see that it added the second data correctly, but it also overwrote the data for the previous index. for k from 1 to nops([indices(thicknesstable)]) do #loop for each structure > print(thicknesstable[k]); #display structure > fprintf(outfile,"%s ",convert(thicknesstable[k],string)); #output structure > m := 1; #reset m index > for i in eVlist do #loop for each eV > fprintf(outfile,"%6.2f ",i); #output eV > MMatrix := Matrix(4,4,shape=identity): #reset MMatrix > # do Mmatrix multiplication here > for z from 1 to (nops([indices(layerelementtable)])-1) do #loop for each layer > .... > end do; #layer loop > if( (MMatrix[2,1] * MMatrix[3,3] - MMatrix[2,3] * MMatrix[3,1])=0 ) #check for divide by zero > then RotEllip := 0 > else > RotEllip := evalf( (MMatrix[4,1] * MMatrix[3,3] - MMatrix[4,3] * MMatrix[3,1]) / (MMatrix[2,1] * MMatrix[3,3] - MMatrix[2,3] * MMatrix[3,1]) ); #answer in radians > RotEllip := evalf(180 / Pi * RotEllip); #answer in degrees > end if; > fprintf(outfile,"%-12.11z G ",RotEllip); #output RotEllip > MMatrixListReal[m] := [i, Re(RotEllip)]; #accumulate table of x,y values > MMatrixListImag[m] := [i, Im(RotEllip)]; #accumulate table of x,y values > m := m+1; #increment m index > end do: #eV loop > PlotTable[thicknesstable[k]] := eval(MMatrixListReal); #accumulate table of tables of plot coords > print(k); print(PlotTable); #display K index, and current instance of table > end do: #structure loop > close(outfile); [1000., 99999.] 1 table([ [1000., 99999.] = table([1 = [1., 0.6492963288], 2 = [1.2, 0.6538797292], 3 = [1.4, 0.6168725326], 5 = [1.8, 0.4962540369], 4 = [1.6, 0.5622218344], 7 = [2.2, 0.3790817814], 6 = [2., 0.4325989543], 10 = [2.8, 0.2777480726], 11 = [3., 0.2634510005], 8 = [2.4, 0.3359132568], 9 = [2.6, 0.3018061672], 15 = [3.8, 0.2778275325], 14 = [3.6, 0.2673446757], 13 = [3.4, 0.2601306211], 12 = [3.2, 0.2581084863], 21 = [5., 0.2988081601], 20 = [4.8, 0.3122830592], 16 = [4., 0.2897116057], 17 = [4.2, 0.3010779872], 18 = [4.4, 0.3100941592], 19 = [4.6, 0.3147505112] ]) ]) [10000., 99999.] 2 table([[10000., 99999.] = table([1 = [1., 0.5971520529], 2 = [1.2, 0.5874894527], 3 = [1.4, 0.5693114642], 5 = [1.8, 0.4944405889], 4 = [1.6, 0.5399861375], 7 = [2.2, 0.3874399519], 6 = [2., 0.4403954838], 10 = [2.8, 0.2798496732], 11 = [3., 0.2650409648], 8 = [2.4, 0.3413263809], 9 = [2.6, 0.3050384776], 15 = [3.8, 0.2789821391], 14 = [3.6, 0.2684890025], 13 = [3.4, 0.2613346141], 12 = [3.2, 0.2594649193], 21 = [5., 0.2998651769], 20 = [4.8, 0.3134373985], 16 = [4., 0.2908751206], 17 = [4.2, 0.3023065414], 18 = [4.4, 0.3113699882], 19 = [4.6, 0.3159738365] ]), [1000., 99999.] = table([1 = [1., 0.5971520529], 2 = [1.2, 0.5874894527], 3 = [1.4, 0.5693114642], 5 = [1.8, 0.4944405889], 4 = [1.6, 0.5399861375], 7 = [2.2, 0.3874399519], 6 = [2., 0.4403954838], 10 = [2.8, 0.2798496732], 11 = [3., 0.2650409648], 8 = [2.4, 0.3413263809], 9 = [2.6, 0.3050384776], 15 = [3.8, 0.2789821391], 14 = [3.6, 0.2684890025], 13 = [3.4, 0.2613346141], 12 = [3.2, 0.2594649193], 21 = [5., 0.2998651769], 20 = [4.8, 0.3134373985], 16 = [4., 0.2908751206], 17 = [4.2, 0.3023065414], 18 = [4.4, 0.3113699882], 19 = [4.6, 0.3159738365] ]) ]) thanks James
﻿