Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

If statement using a vector 3

Status
Not open for further replies.

1clown

Mechanical
Sep 19, 2011
13
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

Recommended for you

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
 
 http://files.engineering.com/getfile.aspx?folder=41077dc2-94a7-4b36-ad43-057ac83f9c7f&file=Mathcad_-_eng_tips_question_1.pdf
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
 
 http://files.engineering.com/getfile.aspx?folder=a8e61166-f338-40ee-9bfe-a562e6f697d8&file=If_statement.mcd
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?
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor