cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Vector error with counter

dsochor
5-Regular Member

Vector error with counter

The attached Mathcad prime 3.1 file and jpg is attempting to make a vector using a counter but I get the error as shown. Why does Prime not let me make the results a vector? My ultimate goal is to find local and global max/min of the resulting vector.

Also, is there a way to display the vectors horizontally? The transpose command doesn't appear to work on i.

1 ACCEPTED SOLUTION

Accepted Solutions
MJG
18-Opal
18-Opal
(To:dsochor)

Your definition of i is a range variable, not a vector.  That's why you don't get your desired results, and also why you cannot transpose i.

You need to define i as a vector.  Here is one approach:

View solution in original post

10 REPLIES 10
VladimirN
24-Ruby II
(To:dsochor)

Just type a(i):=...

dsochor
5-Regular Member
(To:VladimirN)

Thank you Vladimir!

VladimirN
24-Ruby II
(To:dsochor)

You're welcome. The only thing that I didn't pay attention that you want to work with a vector further.

MJG
18-Opal
18-Opal
(To:dsochor)

Your definition of i is a range variable, not a vector.  That's why you don't get your desired results, and also why you cannot transpose i.

You need to define i as a vector.  Here is one approach:

dsochor
5-Regular Member
(To:MJG)

Thanks Mark, is there a way to combine i and a into a single matrix (with different units) so that angle and weight can be displayed side-by-side?

MJG
18-Opal
18-Opal
(To:dsochor)

"augment" puts columns side-by-side:

similarly, "stack" puts rows one on top of the other

Unfortunately, I don't think you can control the units it displays in a mixed-unit matrix.

Edit: You're probably aware that you can change the worksheet's "unit system" and that will obviously change the force units displayed (to lbf for USCS), but I mean that you cannot manually change the display of a mixed-unit matrix to show other units (such as degrees for your angle or kip force).

dsochor
5-Regular Member
(To:MJG)

Thank you again!

MJG
18-Opal
18-Opal
(To:dsochor)

Does anyone know why the calculation in the bottom-left of OP's worksheet DOES work?  I would have expected the same error.

Werner_E
24-Ruby V
(To:MJG)

You can evaluate a function with a range as argument, but you can't assign the result to a variable. The result is not a range, not  a vector, its just some kind list. Obviously a dat type not designed to be stored in a variable.

StuartBruff
23-Emerald II
(To:MJG)

If Prime has effectively kept the same underlying type system as Real Mathcad, then the value of the range variable will be stored as some kind of structure (a range) that holds the values (a,b..c).  It is neither a scalar and nor an array (In Mathcad 11, you could use the (Maple-based) symbolic processor to demonstrate this by looking at its type).

AFAICT, whenever Mathcad sees a range on the left hand side of an evaluation or definition operator, it will treat this as an instruction to iterate over the complete set of values implied by the range (eg, -30,-25,-20 .. ).

If the operator is a definition operator, then Mathcad will expect any ranges to be in an array index.  A range may or may not occur on the right side of the definition (although it usually will be there).  If a range is used on the right hand side, then it must also be used on the left hand side for Mathcad to iterate over it.  Otherwise, Mathcad will evaluate it as a range - this usually leads to errors because few operators or functions take a range as an argument (eg, indexing an array requires an integer, a range is a range, hence the frequent cries for help when somebody has used a range variable on the right hand side of an equation only).

See the image below for some further information.

Stuart

Top Tags