×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*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.

# If statement using a vector3

## If statement using a vector

(OP)
Hi Guys, I need to use an if statement and one of the inputs is a vector and I cannot get it to work.
I have an equation like this

Z:=if(C*D > min(A,B),min(A,B),C*D)

Where C and D are both vectors.
The message I get is that they need to be scalar quantities. I have tried converting A & B into vectors and using a basic program but no luck.
Any help would be appreciated.
Thanks
Replies continue below

### RE: If statement using a vector

(OP)
Hi Guys thanks for the answers. I still cannot get this to work. I have tried examples like yours and they work fine.
I did discover that one of my values that I thought was a vector was actually a scalar number.I have a min function above comparing a fixed number and a vector and I had assumed (idiot) that it would have pulled down the vector.
I have tried multiplying the vector and scalar (creating another variable) previous to this function and using this in the if function but still no luck.
I have included a copy of my equation. Your help is greatly appreciated.
Thanks

### RE: If statement using a vector

See if the attached is what you're looking for.  The two are identical, test1 uses a program, and test2 uses a range variable.  The program is more flexible, but some people prefer range variables.  If this isn't what you're looking for, please describe the output you are expecting.

Peter

### RE: If statement using a vector

When you multiply the vector rein by the scalar Height, you get a vector.  When you multiply the two A scalars together, you get a scalar.  You can't compare a vector to a scalar.

You could use max(reinadd.n ⋅Heightrein.n) and compare this with max(A1.n ,A2.n).  This will compare the highest value of the product (112.25 mm²) with the higher of A1.n and A2.n.  Is this what you want?

### RE: If statement using a vector

(OP)
Thanks guys I have got this to work. I used the test 2 option of Peters recomendation and it works a treat as I required a vector output. Thanks also to jghrist for your input.

#### 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.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!