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

Best practice: list of variables in mathcad v.11 and above

Regular Member

Best practice: list of variables in mathcad v.11 and above

Most of the time I use MC v.11, but I did not find (in my rapid checking) anything even in v. 15. Probably there is something in Prime, but it is not for me, yet. So here the inquiry.

In other similar Math apps, there is a window or a command to list the variables used so far in the worksheet.

How do MC users deal with it?

So far I tried to keep up with the list of variables in a separate Excel file, or separate MC worksheet.

But I also tought to use a vector in the same MC worksheet with an initial column vector of definitions and the command "stack" to update it, like this:

ListV := ("v = velocity" "s =space")

(and when a new variable is defined)

ListV := stack (ListV, "a =acceleration")

So anytime I type ListV I have the list of variables and a short definition of them (would be nice to have them in alphabetic order). Does anyone use a similar method or a better one? How does one deal with a worksheet with dozen if not hundred of variable definitions?

Thanks for any feedback.

16 REPLIES 16

Re: Best practice: list of variables in mathcad v.11 and above

In M11 to M15 it is possible to wrote a component that will iterate over a worksheet and, via the xml properties, locate and list all of the defined variables.

Stuart

Re: Best practice: list of variables in mathcad v.11 and above

Thanks Stuart,

but it is a bit cryptid for my not-so-high-expertise. Do you have a working example for instance to expand a bit how it works? Can it function with an open worksheet?

In fact, often I need the list when I want to define a variable. In several occasions I am pretty sure that I already did it. However the time spent searching where is it in the worksheet, is higher than the time spent re-writing it.

Re: Best practice: list of variables in mathcad v.11 and above

"(would be nice to have them in alphabetic order)". Use:

ListV := sort(stack (ListV, "a =acceleration"))

To separate the variable names from their definition (and allowing them to be sorted individually) you could use a matrix (2 columns, n rows):

ListV := ( "v" "velocity"

"s "space" )

ListV := csort(stack (ListV, ( "a" "acceleration" ) ), ORIGIN)

or

ListV := csort(stack (ListV, ( "a" "acceleration" ) ), ORIGIN+1)

You can also add a column with the actual value of each variable:

ListV := ( "v" v "velocity"

"s" s "space" )

And of cours you can write the list of variables to a text file with:

WRITEPRN(".\Variables.txt") := stack( ( "Name" "Value" "Definition" ), csort(ListV,ORIGIN))

Success!

Luc

Re: Best practice: list of variables in mathcad v.11 and above

Thanks Luc, nice touches.

Yet, I am a bit puzzled: Am I the only one (or one of the few) that misses the feature "list of used variables", and that looks for workarounds?

Re: Best practice: list of variables in mathcad v.11 and above

anthony Queen wrote:

Thanks Stuart,

but it is a bit cryptid for my not-so-high-expertise. Do you have a working example for instance to expand a bit how it works? Can it function with an open worksheet?

Not to hand, I'm afraid. I think a search of the collab might turn up an example, though.

In fact, often I need the list when I want to define a variable. In several occasions I am pretty sure that I already did it. However the time spent searching where is it in the worksheet, is higher than the time spent re-writing it.

Go to Tools/Preferences in the main menu bar. In the General Tabl of the Preferences dialog, ensure you have the "Context-sensitive equals signs" tick box checked. Then, whenever you type, say, x=, if it's not defined, then x:= will appear rather than x=. With the box checked Mathcad, will assume you want to create a new variable.

Alternatively, got to the Warnings tab on the Preferences dialog and check the warnings on redefinitions of User Defined functions, variables and/or vectors and matrices, as required.

The first method is generally less confusing to look at.

Stuart

Re: Best practice: list of variables in mathcad v.11 and above

Thanks again.

From v.11.2, if I remember correctly, an already assigned variable comes up with a green underlined sign. That's ok. But, I often face the opposite case: I want to re-use a variable already written above, but I cannot exactly recall the full and precise name, given that I have thirty or more of them. That's where a list of variables (in use by many other Math app) comes very handy.

Re: Best practice: list of variables in mathcad v.11 and above

Hi Anthony,

No, you're not the only one. There have been more requests. I personally don't need it. If I want to know if a variable is already used, I first (try to) print its value (Variable=). Besides I have the redefinition flag enabled, so a variable gets flagged when redefined.

And I don't use MC's built-in unit definitions of feet, pounds and what have you. Instead I use my own set (SI, with all prefixes defined) that is specially tagged so no confusion between a variable and a unit.

Also I tend to use functions to perform my calculations, so that the section(s) with actual calculations that use design parameters are small: single glance overview.

Success!
Luc

P.S.

Ah, I see now that the 'printing' of the actual values of the variables has a catch. It will print the values that are current at the time of the last variable definition added to ListV; as opposed to the values that are current on print time...

Re: Best practice: list of variables in mathcad v.11 and above

No, you are not alone in wanting more support from Mathcad. Here's (one of many) posts that mention it (symbol concordance). http://communities.ptc.com/message/159782#159782. Unfortunately, the "collab.mathsoft.com" references are no longer reachable.

There were many, much older requests, dating back to at least M11 (ie, over a decade), most of them lost in the transition from the Mathsoft Collaboratory to PTC's Community.

I have to confess to being truly disappointed that neither Mathsoft nor PTC have really made any effort to improve and extend the Mathcad basic method of operation. There is so much they could have done to improve the capability of the product and its usability, yet little has effectively changed since Mathcad 11 (and, indeed, has taken several steps backwards with Prime).

Stuart

Copied from the above referenced thread:

The target user domain is a key factor in determining what the product should do. I believe that thi...





http://collab.mathsoft.com/~Mathcad2000/read?112720,63 mentions, I believe that Mathcad should be viewed from several points of view to see what capabilities it should have.

The Whiteboard

The first viewpoint I take is that which led to the invention of Mathcad - The Whiteboard.

The concept of the whiteboard has moved on over the years to the extent that it is common to encounter active (or at least semi-passive) whiteboards that allow the user to capture what's written on a PC, with automatic text recognition and vectorization routines that 'tidy up' drawings. It's not too difficult to extend the concept to a more active whiteboard that does this live (eg, a fast touch-sensitive screen + supporting tools, eg automatic or on-demand visual 'tidying up' with automatic interpretation). It should have a drag and drop capability, so that, say, a variable could be selected and dragged into a place holder, or a subset of a matrix could be selected and copy-dragged elsewhere. Now imagine yourself either thinking things through by yourself or giving a lecture/presentation and think what features you'd find useful in such an active whiteboard - that's what Mathcad should have, eg, quick text formatting without quotes, or the ability to choose either freehand drawing or the ability to pick from a palette of simple drawing tools.

A major implication of this is that notation should be flexible to allow the maths Prof their Jν(x) whilst letting the 'programmer' enter J(n,x). Instantly, this means both left and right superscripts/subscripts and the ability to format them independently of the main name.

Detailed Analysis/Implementation

It's fairly easy to imagine that the Whiteboard is used to sketch out the design for some particular problem and get buy-in to progress to a more detailed analysis (eg, Whiteboard: "I've got this great idea for a new nozzle design! Here's the outline ..." followed by Detailed Analysis: "OK, looks promising. Flesh it out and generate some test data we can drop into the lab people."). This would be an extension of the Whiteboard with improved data presentation and more automated control over plots and animations, and access to their data/images.

Documentation/Publication/Presentation

The next stage, having done the donkey work and got some results back from the lab/production people, is to formally document it and/or prepare it for publication or presentation. This requires an additional set of tools, such enhanced text formatting, equation numbering, and style-guides (plus checkers) and layout enhancements, such as 2-column presentation. As you've mentioned elsewhere, the ability to output in pdf or LaTex format would be essential (built-in not bolted-on, so that, for example, default output file names would be automatically related to the worksheet name.

I think all of the above are in keeping with PTC's (and Mathsoft as was) aim of having Mathcad at the heart of a one-stop calculation management system. Whilst I'm aware of the dangers of overkill (the UML saga referred to), there are a lot of capable and competent competitors out there and not doing enough is a much a killer as capability bloat.

#

Here's a summary of some feature requests, in no particular order


Stuart

1. add plot component programming interface:
… a. allow component to return complete param...





http://collab.mathsoft.com/read?94485,12 (worksheet shows potential for enhancement using (undocumented) 3D plot component to set titles, define axes, etc)

3. http://collab.mathsoft.com/read?58646,12 (original request)

4. add multi-dimensional array capability, should:
… a. support hyper-rectangular arrays
… b. provide ragged nested array index support
… c. have an empty array
… d. support tensor operations
… e. should support tensor notation (eg superscript)
… f. accept string input and provide string output of array values (for example of this see http://collab.mathsoft.com/read?74389,11 )

5. add set support (eg, array to set, set inclusion, set join)

6. provide mnemonic names for functions defined as operators (eg, '+' available as 'add')

7. enhance definition and display capability:
… a. provide keyboard shortcuts for prefix, infix, postfix and tree operators
… b. allow user to replace standard operator symbols with other function names (eg, 2+3 could become 2 div 3)
… c. allow tree display of nested vectors
… d. convert expression between Mathcad and 'standard' programming string (eg, MuPad, Excel or C)

8. enhance symbolic capability:
… a. allow deferred evaluation (useful for passing expressions to functions rather than trying to evaluate them first)
… b. allow user to create names programmatically (eg, string to variable, so could write a:=3, b:=4, c:=a+var("b"), where var provides the conversion)

9. allow direct access to region properties (including values)

10. see thread starting at message http://collab.mathsoft.com/read?66893,77

11. provide multiple views onto a worksheet (eg, similar to MS Excel's multiple windows or split view (top/bottom)

12. provide automatic region numbering schemes (eg, global paragraph numbering, equation/figure/table numbering)

13. allow programmatic access to a component's script (both read and write)

14. allow direct means of viewing a component's script (ie, without opening it)

15. provide symbol concordance

16. (to support the latter 2 features, provide a view onto the worksheet that lists all 'hidden' attributes (such as ORIGIN, TOL or default result settings)

17. improve page breaks to avoid splitting text over a page break (particularly wrt programs)

18. provide rectangular area / sub-worksheet capability

19. ability to extend Mathcad by adding worksheets / e-books as libraries in a similar way to extension packs, rather than having to 'include' them.

20. provide programmatical control of animation (in addition to the clunky and ancient dialog method)

21. add subvector function to complement submatrix (I use my subvector implementation fairly frequently)

22. add 'sequences' as a proper data type that the user can define outside of a for-loop definition and can use in place of a range (as a range is a sub-type of a sequence).

23. formalize and make available the Mathsoft Programming Language.

Re: Best practice: list of variables in mathcad v.11 and above

In M11 to M15 it is possible to wrote a component that will iterate over a worksheet and, via the xml properties, locate and list all of the defined variables.

Not MC11. The XML file format is only MC12 and later.