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 03/25/13 7:32pm In Response To 'Re: Re: Help with creating matrix from another ...'---------I need an answer to a question. I now understand how to do this. In[1]:= x=49;y=50; {Map[Last,Position[a,x]],Map[Last,Position[a,y]]} Out[2]= {{22,13,10,1},{23,14,11,2}} That lets me calculate this. In[3]:= Plus@@Map[Part[b,Sequence@@#]&,Transpose[%]] Out[3]= b[[1,2]]+b[[10,11]]+b[[13,14]]+b[[22,23]] But if I do this. In[4]:= x=1;y=7; {Map[Last,Position[a,x]],Map[Last,Position[a,y]]} Out[5]= {{1},{10,1}} then I do not know what to do. 1 appears one time and 7 appears two times. I understand if the x value or the y value appears zero times then the result is zero. But what do I do if the x and y values appear more than zero times but not the same number of times? Your post does not tell me what to do. If the result should be zero when the x value and y value appear more than zero times, but not the same number of times then this may be your code. In[6]:= Table[ If[ (xp = Map[Last, Position[a, x]]) == {} || (yp = Map[Last, Position[a, y]]) == {} || Length[xp] ≠ Length[yp], 0, Plus @@ Map[Part[b, Sequence @@ #] &, Transpose[{xp, yp}]] ], {x, 1, 150}, {y, 1, 150}] 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