Vector error with counter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Just type a(i):=...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you Vladimir!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
You're welcome. The only thing that I didn't pay attention that you want to work with a vector further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
"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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Does anyone know why the calculation in the bottom-left of OP's worksheet DOES work? I would have expected the same error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
