Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 34651

Questions on the manipulation of matrices in Mathematica.

0 votes
2 answers
225 views

Flipping random elements in a matrix

[A]; lis1 = Most[ArrayRules[A]]; lis2 = RandomChoice[lis1, n] ; lis2 = Map[ReplacePart[#, 2 -> -2] &, lis2[[1 ;; n]]]; S = SparseArray[lis2, {size[[1]], size[[1]]}, 0] + A ;]; It takes an adjacency matrix … still need to tweak is making sure I the entries are flipped symmetrically, i.e. if the (1,2) entry is picked by RandomChoice then I need to also add the (2,1) entry of lis1 so that S is a symmetric matrix
TeeJay's user avatar
  • 187
7 votes
2 answers
1k views

Replacing elements of a matrix

I'm trying to write a program that takes a given matrix A of 1's and 0's and flips a designated amount of 1's to -1's. …
TeeJay's user avatar
  • 187