Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'manipulate indices' topicStudent Support Forum > General > "manipulate indices"

Next Comment >Help | Reply To Topic
Author Comment/Response
09/01/12 07:50am

I want to manipulate one index of a matrix element, while I want to hold another unchanged.

Here is my simple code including explanation step by step.


"Assume I define the M matrix here."

"here I generate a list"

GG = Array[G, {1, 20}];

"I will assign each element of GG from the M matrix."

Do[F = Part[M, 1, 1];
G[1, k] = { F};
, {k, 0, 20, 1}]

"Now randomly I will pick mth and (m+1)th elements from GG and manipulate those."

m = RandomInteger[{1, 20}];

Wold1 = GG[[1, m]]
Wold2 = GG[[1, Mod[m + 1, 20]]]

l = RandomInteger[{1, 3}];

Wnew1 = {M[[ (want this hold the same) , l]]}
Wnew2 = {M[[l, (want this hold the same)]]}

GG[[1, m]] = Wnew1;
GG[[1, Mod[m + 1, 20]]] = Wnew2;

URL: ,

Subject (listing for 'manipulate indices')
Author Date Posted
manipulate indices serelha 09/01/12 07:50am
Re: manipulate indices Bill Simpson 09/03/12 11:49pm
Next Comment >Help | Reply To Topic