×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

"Invert" vector

"Invert" vector

"Invert" vector

(OP)
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!

RE: "Invert" vector

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: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

RE: "Invert" vector

(OP)
Ohh, I feel stupid now :)

Thanks!

RE: "Invert" vector

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources