Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Help with creating matrix from another matrix' topicStudent Support Forum > General > Archives > "Help with creating matrix from another matrix"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
04/09/13 8:35pm

In Response To 'Re: Re: Re: Re: Re: Re: Help with creating matr...'
---------
I have modified my code.

In[1]:= a = {
{1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9, 31, 32, 33, 34, 35, 36, 40, 41, 42, 37, 38, 39},
{7, 8, 9, 10, 11, 12, 16, 17, 18, 13, 14, 15, 37, 38, 39, 40, 41, 42, 46, 47, 48, 43, 44, 45},
{13, 14, 15, 16, 17, 18, 22, 23, 24, 19, 20, 21, 43, 44, 45, 46, 47, 48, 52, 53, 54, 49, 50, 51},
{19, 20, 21, 22, 23, 24, 28, 29, 30, 25, 26, 27, 49, 50, 51, 52, 53, 54, 58, 59, 60, 55, 56, 57},
{31, 32, 33, 34, 35, 36, 40, 41, 42, 37, 38, 39, 61, 62, 63, 64, 65, 66, 70, 71, 72, 67, 68, 69},
{37, 38, 39, 40, 41, 42, 46, 47, 48, 43, 44, 45, 67, 68, 69, 70, 71, 72, 76, 77, 78, 73, 74, 75},
{43, 44, 45, 46, 47, 48, 52, 53, 54, 49, 50, 51, 73, 74, 75, 76, 77, 78, 82, 83, 84, 79, 80, 81},
{49, 50, 51, 52, 53, 54, 58, 59, 60, 55, 56, 57, 79, 80, 81, 82, 83, 84, 88, 89, 90, 85, 86, 87},
{61, 62, 63, 64, 65, 66, 70, 71, 72, 67, 68, 69, 91, 92, 93, 94, 95, 96, 100, 101, 102, 97, 98, 99},
{67, 68, 69, 70, 71, 72, 76, 77, 78, 73, 74, 75, 97, 98, 99, 100, 101, 102, 106, 107, 108, 103, 104, 105},
{73, 74, 75, 76, 77, 78, 82, 83, 84, 79, 80, 81, 103, 104, 105, 106, 107, 108, 112, 113, 114, 109, 110, 111},
{79, 80, 81, 82, 83, 84, 88, 89, 90, 85, 86, 87, 109, 110, 111, 112, 113, 114, 118, 119, 120, 115, 116, 117},
{91, 92, 93, 94, 95, 96, 100, 101, 102, 97, 98, 99, 121, 122, 123, 124, 125, 126, 130, 131, 132, 127, 128, 129},
{97, 98, 99, 100, 101, 102, 106, 107, 108, 103, 104, 105, 127, 128, 129, 130, 131, 132, 136, 137, 138, 133, 134, 135},
{103, 104, 105, 106, 107, 108, 112, 113, 114, 109, 110, 111, 133, 134, 135, 136, 137, 138, 142, 143, 144, 139, 140, 141},
{109, 110, 111, 112, 113, 114, 118, 119, 120, 115, 116, 117,139, 140, 141, 142, 143, 144, 148, 149, 150, 145, 146, 147}};
c = Table[
xp = Map[Last, Position[a, x]];yp = Map[Last, Position[a, y]];
m=Min[Length[xp],Length[yp]];xp=Take[xp,m];yp=Take[yp,m];(*I added this line to the code*)
If[xp=={}||yp=={}||Length[xp]!=Length[yp], 0, Plus@@Map[b[[Sequence@@#]]&, Transpose[{yp, xp}]]], {y, 150}, {x, 150}];

Now look at only at the first 13 columns and 7 rows of the matrix c to see any errors.

In[3]:= Map[Take[#, 13] &, Take[c, 7]]

Out[3]= {
{b[[1,1]], b[[1,2]], b[[1,3]], b[[1,4]], b[[1,5]], b[[1,6]], b[[1,10]], b[[1,11]], b[[1,12]], b[[1,7]], b[[1,8]], b[[1,9]], b[[1,10]]},
{b[[2,1]], b[[2,2]], b[[2,3]], b[[2,4]], b[[2,5]], b[[2,6]], b[[2,10]], b[[2,11]], b[[2,12]], b[[2,7]], b[[2,8]], b[[2,9]], b[[2,10]]},
{b[[3,1]], b[[3,2]], b[[3,3]], b[[3,4]], b[[3,5]], b[[3,6]], b[[3,10]], b[[3,11]], b[[3,12]], b[[3,7]], b[[3,8]], b[[3,9]], b[[3,10]]},
{b[[4,1]], b[[4,2]], b[[4,3]], b[[4,4]], b[[4,5]], b[[4,6]], b[[4,10]], b[[4,11]], b[[4,12]], b[[4,7]], b[[4,8]], b[[4,9]], b[[4,10]]},
{b[[5,1]], b[[5,2]], b[[5,3]], b[[5,4]], b[[5,5]], b[[5,6]], b[[5,10]], b[[5,11]], b[[5,12]], b[[5,7]], b[[5,8]], b[[5,9]], b[[5,10]]},
{b[[6,1]], b[[6,2]], b[[6,3]], b[[6,4]], b[[6,5]], b[[6,6]], b[[6,10]], b[[6,11]], b[[6,12]], b[[6,7]], b[[6,8]], b[[6,9]], b[[6,10]]},
{b[[10,1]], b[[10,2]], b[[10,3]], b[[10,4]], b[[10,5]], b[[10,6]], b[[1,1]]+b[[10,10]], b[[1,2]]+b[[10,11]], b[[1,3]]+b[[10,12]], b[[1,4]]+b[[10,7]], b[[1,5]]+b[[10,8]], b[[1,6]]+b[[10,9]], b[[1,1]]+b[[10,10]]}
}

Compare this with your spreadsheet "Matrix Assembly Manual Akhir.xlsx"

In[4]:= Map[Drop[#, 2] &, Drop[Take[Map[Take[#, 15] &, First[dati]], 9], 2]]

Out[4]= {
{"1 1", "1 2", "1 3", "1 4", "1 5", "1 6", "1 10", "1 11", "1 12", "1 7", "1 8", "1 9", 0.},
{" ", "2 2", "2 3", "2 4", "2 5", "2 6", "2 10", "2 11", "2 12", "2 7", "2 8", "2 9", 0.},
{" ", " ", "3 3", "3 4", "3 5", "3 6", "3 10", "3 11", "3 12", "3 7", "3 8", "3 9", 0.},
{" ", " ", " ", "4 4", "4 5", "4 6", "4 10", "4 11", "4 12", "4 7", "4 8", "4 9", 0.},
{" ", " ", " ", " ", "5 5", "5 6", "5 10", "5 11", "5 12", "5 7", "5 8", "5 9", 0.},
{" ", " ", " ", " ", " ", "6 6", "6 10", "6 11", "6 12", "6 7", "6 8", "6 9", 0.},
{" ", " ", " ", " ", " ", " ", "10 10+1 1", "10 11+1 2", "10 12+1 3", "10 7+1 4", "10 8+1 5", "10 9+1 6", "1 10"}
}

I believe more of the numbers in my matrix c are correct now.

I do not understand why column 13 and rows 1..6 are zero in your spreadsheet but nonzero in my matrix.

I do not understand why elements below the diagonal are blank in your spreadsheet but nonzero in my matrix.

If you can explain why a a matrix entry c[[row,column]] is incorrect in my matrix and what the value for c[[row,column]] should be then perhaps I can understand and correct this.

URL: ,

Subject (listing for 'Help with creating matrix from another matrix')
Author Date Posted
Help with creating matrix from another matrix Anton Siswo 03/24/13 01:15am
Re: Help with creating matrix from another matrix Bill Simpson 03/24/13 11:53pm
Re: Re: Help with creating matrix from another ... Anton Siswo 03/25/13 11:35am
Re: Re: Re: Help with creating matrix from anot... Bill Simpson 03/25/13 7:32pm
Re: Re: Re: Help with creating matrix from anot... Bill Simpson 03/25/13 10:20pm
Re: Re: Re: Re: Help with creating matrix from ... Anton Siswo 03/31/13 7:22pm
Re: Re: Re: Re: Re: Help with creating matrix f... Bill Simpson 04/01/13 00:06am
Re: Re: Re: Re: Re: Re: Help with creating matr... Anton Siswo 04/01/13 5:52pm
Re: Re: Re: Re: Re: Help with creating matrix f... Bill Simpson 04/01/13 10:44am
Re: Re: Re: Re: Re: Re: Help with creating matr... Anton Siswo 04/08/13 04:52am
Re: Re: Re: Re: Re: Re: Re: Help with creating ... Bill Simpson 04/09/13 8:35pm
Re: Re: Re: Re: Re: Re: Re: Re: Help with creat... Anton Siswo 04/11/13 10:58am
Re: Re: Re: Re: Re: Re: Re: Help with creating ... Bill Simpson 04/09/13 9:54pm
Re: Re: Re: Re: Re: Re: Re: Re: Help with creat... Anton Siswo 04/10/13 9:41pm
Re: Re: Re: Re: Re: Re: Re: Re: Re: Help with c... Bill Simpson 04/12/13 00:35am
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Help wi... Anton Siswo 04/16/13 07:19am
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Hel... Bill Simpson 04/16/13 7:48pm
Re: Help with creating matrix from another matrix Anton Siswo 03/26/13 11:29pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic