Pages: [1]   Go Down
Author Topic: How to manipulate a matrix.  (Read 398 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Lets say I have..
int matrix[5][5]={{0,0,0,0,0},{1,1,1,1,1},{2,2,2,2,2},{3,3,3,3,3},{4,4,4,4,4}};
How do I manipulate this matrix to make it look like...
{{0,0,0,0,0},{0,0,0,0,0},{1,1,1,1,1},{2,2,2,2,2},{3,3,3,3,3}}
then
{{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{1,1,1,1,1},{2,2,2,2,2}}
and so on.....
What I basically want to do is shift every row down by one or up by one.
Any suggestions???
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8958
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

'for' loops.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6783
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What John meant is that C has not particular magic functions to do any matrix manipulation; you have to do it yourself, one element at a time...
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26488
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
you have to do it yourself, one element at a time...
Or a row ata time, using memcpy
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: