Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Invert" vector

Status
Not open for further replies.

erk00

Structural
Joined
Jan 29, 2009
Messages
7
Location
SE
Hi

How do I automatically invert a vector

Say that I have someting like: [4 5 6 8 56 -2] and want it to change places into [-2 56 8 6 5 4] ??

Is there a ready function for this+ i have tried programming it without good results so far. The programs I am trying to do won't let me put a vector as output...

Thanks for any help!
 
Then don't use a program

something like

i:1;6

b[i:0

b[(6-i):a[i

will work perfectly and can easily be mod'd

Cheers

Greg Locock

SIG:Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Ohh, I feel stupid now :)

Thanks!
 
there is a built-in function called 'reverse' that will do what you want.

If you want a programmed version, the following program should work

Reverse(v):= n<-last(v)
for k element-of 0..n
|w[(n-k)<-v[k
w
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top