eve
Joined: 04 Jan 2007 Posts: 1
|
Posted: January 4, 2007 1:11 PM Post subject: Matrix stuff: appliing sin to a vector... |
|
|
Is there any way i can apply a function to all elements of a matrix?
ie
[1,2,3,4]->a
sin(a)
gives me a dimension error...
and also:
can i choose like in matlab a series of elements of a matrix rather choosing them one by one?
like say i want second and third row to form a new matrix, what should be the sintax?
ie
[1,2,3;3,2,1;1,2,3]->a
a[[2,3],[1,2,3]] or a[2:3,:] ???
Thanks so much!!!! |
|
bostonvaulter
Joined: 13 Oct 2006 Posts: 43 Location: USA
|
Posted: January 27, 2007 1:11 PM Post subject: |
|
|
well i'm not sure how you would take sin of a matrix, because i can't get it to work. But you can select individual cells of a matrix by doing something like this matrix[0,0] to give you the first cell. then change the 0's to the number you want.
For functions other than sin() it easy. to multiply every cell in the matrix by 5, just do 5*matrix
hope this helps |
|