Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross 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
Jan 29, 2009
7
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!
 
Replies continue below

Recommended for you

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!
 
Nah, I'd puzzle over that in Matlab.



Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
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