On 12/6/2009 4:34:16 PM, dmg wrote:
>Yes, I suppose it is - I think
>the problem is the nature of
>"programming" using Mathcad
>constructs vs say fortran or
>C++.
Yes, it's a very different environment.
>In Mathcad a "program"
We refer to it as a worksheet.
>can consist of a number of
>smaller programmed elements in
>the same file, as is the case
>here.
You can enter expressions in a worksheet much the same way as you would write them on paper. Execution order is top left to bottom right, just as you would read a page. Just as in Fortran or C++ you can create a function that can be called later in the worksheet, or you can just evaluate an expression and assign the result (which is not restricted to being a scalar value) to a variable. You also have ways to create conditional statements and "loops" in the worksheet. For conditional statements you have the "if" function. For "loops", you have range variables. Note that a range variable is an iterator, just like a loop variable in Fortran or C, it is not a vector of values. This seems to confuse a lot of people. If I write
i:0;10
x[i:i/10
then the latter expression is evaluated for each value of i, which means x becomes a vector of values.
Sometimes it's difficult or impossible to do what you want just by typing one line statements in the worksheet though, in which case Mathcad has what are termed "programs". Just like a single line statement, a program can either assign a value to a variable, or it could define a function.
>I was originally
>thinking along the lines of
>how it would be done in a
>single program in, say
>fortran.
Confusing terminology!
>This approach is
>better I think.
Well, we all think so 🙂
Richard