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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

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

anthonyQueen
8-Gravel

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

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

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.

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

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.

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 this domain should be as wider than simply 'engineering' (whatever that is, it covers a whole host of disciplines from the highly complex "Pass me that hammer would you" to the trivial "solar sail fly-by...





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 parameter set (eg, as one nested array or by specific functions)
… b. allow user to programmatically set parameters (eg, pass back complete parameter set or by specific function)
… c. add capability to ret...



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.

RichardJ
19-Tanzanite
(To:StuartBruff)

Sorry, but all your requests, as well as many others, are on hold until one important request is fulfilled. That request is "give us in Prime what we already had in MC11 and/or MC15". Unfortunately it is unclear when, if ever, this one request will be fulfilled

StuartBruff
23-Emerald II
(To:RichardJ)

Do you mean I've wasted my time buying a new whiteboard for home use?

----------------------------------------------

I've just bought a couple of Arduinos and a Raspberry Pi for me my 9-yr old to play with, and he can do that via Mathematica or the home edition Matlab/Simulink I'm seriously thinking about buying.

There are a few Mathcad enthusiasts up here in my new Glasgow-based optronics job. All of us agree that getting started and documenting projects is far easier in Mathcad than Matlab (the standard and preferred tool of choice) but all bemoan the lack of progress in getting a modern product that will inherently and actively support the life-cycle in the ways I've described above.

Given the capabilities of Matlab, with its extensive range of toolboxes and Simulink capability, Mathcad really can't compete in purely number-crunching terms. But what it does have is the potential to make development substantially easier and better documented, and therefore more cost-effective than purely 'text' based documentation.

Ah well. I expect Mathematica (or some other product) will migrate into becoming what Mathcad should have been.

Stuart

I am also disappointed of the closer of mathsoft collaborative forums, and other similar restrictions (like the banning of all worksheet examples as a free download). I do not like programs that become monsters like matlab. But it is a pity that MathCad did not make some incremental progress, given its superior interface and usability. You are experts as I am a novice. Do you think as impossible that PTC will review its plans and return to improve MC 15?

anthony Queen wrote:

.... Do you think as impossible that PTC will review its plans and return to improve MC 15?

It depends. If you believe in infinite parallel universes then I suppose it is conceivable that there might be one universe in which this happens. I don't think it's our universe, though.

PTC will develop Prime and drop Mathcad as we know it - one can only hope that Prime gets some of the capabilities that we want some time before the Sun leaves the Main Sequence.

Stuart

Do you think as impossible that PTC will review its plans and return to improve MC 15?

Not completely impossible. If all the neurons in several peoples brains spontaneously rearranged themsleves into new configurations via quantum tunneling effects, then they might change their minds.

StuartBruff
23-Emerald II
(To:RichardJ)

Richard Jackson wrote:

Do you think as impossible that PTC will review its plans and return to improve MC 15?

Not completely impossible. If all the neurons in several peoples brains spontaneously rearranged themsleves into new configurations via quantum tunneling effects, then they might change their minds.

Sadly, Pauli's Third Exclusion Principle comes into force and prevents this. No User-Desired Feature and Developer's Implementation Plan can occupy the same Universe.

And if that weren't sufficient, there's always the corollary of Murphy's Law that ensures said feature is neglected, inverted, distorted, or otherwise transmogrified, in such a way that makes it impossible for said feature to ever be realizable.

Stuart

RichardJ
19-Tanzanite
(To:StuartBruff)

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.

StuartBruff
23-Emerald II
(To:RichardJ)

Richard Jackson wrote:

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.

True. Typo - I meant M12. Although, I think I had a look at getting the names from one of the M11 output formats.

Stuart

LucMeekes
23-Emerald III
(To:anthonyQueen)

"(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

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?

LucMeekes
23-Emerald III
(To:anthonyQueen)

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

Top Tags