Go Down

### Topic: How to manipulate a matrix. (Read 674 times)previous topic - next topic

#### vallesvera.manuel

##### Apr 22, 2011, 02:57 am
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???

#### johnwasser

#1
##### Apr 22, 2011, 03:12 am
'for' loops.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

#### westfw

#2
##### Apr 22, 2011, 09:52 am
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...

#### AWOL

#3
##### Apr 22, 2011, 12:59 pm
Quote
you have to do it yourself, one element at a time...

Or a row ata time, using memcpy
"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.
I speak for myself, not Arduino.

Go Up