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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

please explain error message

drgriffin
1-Newbie

please explain error message

This file gives an error, I have another that is identical as far as I can see that works. Can someone explain why this one doesn't
9 REPLIES 9
StuartBruff
23-Emerald II
(To:drgriffin)

On 12/18/2009 8:23:44 AM, dmg wrote:
>This file gives an error, I
>have another that is identical
>as far as I can see that
>works. Can someone explain
>why this one doesn't

Could you please post it in M11 format?

Stuart


StuartBruff
23-Emerald II
(To:drgriffin)

On 12/18/2009 8:23:44 AM, dmg wrote:
>This file gives an error, I
>have another that is identical
>as far as I can see that
>works. Can someone explain
>why this one doesn't

Did the other one have a symbolic evaluation as well? I've had a play in M13, but my M13 doesn't like evaluating the conditional operator (V()*V()>0.

I presume you meant to have a 'stack' at the end of the function?

Stuart

(sorry for the delay - lunch!)

The version that works (just posted) works in 14 and 11. What do you mean by "stack"...nested vectors ? If so, yes
StuartBruff
23-Emerald II
(To:drgriffin)

On 12/18/2009 10:07:29 AM, dmg wrote:
== What do you mean by "stack"...nested vectors ? If so, yes

You can't return a list of items by typing, for example:

a,b,c,d

If you want to return multiple items, you have to do so via a vector. You can do this by, as in the 'working' version, creating an array

[a,b,c,d]

or by using the 'stack' function, that joins the items together to form a vector (note that stack is primarily meant for joining 2 or more vectors or equal-column arrays)

stack(a,b,c,d)

Also note that Mathcad vectors must all have the same dimension, hence the division by m to get s,up&down to stack with i )

Stuart
RichardJ
19-Tanzanite
(To:drgriffin)

If you remove the symbolic evaluation the error message is more useful. It tells you that the forms of your possible return values are not compatible (SUC again). One is a string, and the other (the one at the end) is a comma separated list, not an array. If you want an array you can either enter a matrix with 4 placeholders, and put the return values in each placeholder (which is what Alvaro did), or you can use the stack or augment functions to create an array from the arguments (which is what Stuart did). Note that if the return values are themselves vectors then Alvaro's method returns a nested array, whereas Stuart's requires that the vectors all have the length, and returns a matrix.

Richard

On 12/18/2009 10:19:06 AM, rijackson wrote:
>Note that if the
>return values are themselves
>vectors then Alvaro's method
>returns a nested array,
>whereas Stuart's requires that
>the vectors all have the
>length, and returns a
>matrix.

Attached is thinking in what to return a nested array. Stuart matrix as answer is more 'proffessional', and the nested array is more 'pedagogical', or this is what I think.

Regards. Alvaro.

PD: I don't see that Stuart was answer the problem when upload the file, because are in different threads.
RichardJ
19-Tanzanite
(To:AlvaroDíaz)

On 12/18/2009 11:45:34 AM, adiaz wrote:

>Attached is thinking in what
>to return a nested array. Stuart matrix
>as answer is more 'proffessional', and
>the nested array is more 'pedagogical',
>or this is what I think.

I would also have chosen a nested array, because the dimensions of the returned variables are not all the same. I think Stuart assumed the comma separated list was supposed to be the arguments to a function, and therefore added the function name.

Richard

On 12/18/2009 11:45:34 AM, adiaz wrote:
== Attached is thinking in what to return a nested array. Stuart matrix as answer is more 'proffessional', and the nested array is more 'pedagogical', or this is what I think.

Horses for courses, as the saying goes. I don't think one is 'more professional'; I'm simply more used to thinking 'function' than 'data' and did, as Richard surmises, assume the results would be scalars.

Indeed, one must take when using stack, as it sometimes doesn't give the Intended Result (ie, a nested vector as opposed to joining two vectors into a single vector).

There have been occasions when I've wanted to retain the identity of the item's I'm joining together and not have vectors merge together.

See attached

Stuart

It's a very interesting function. The only observation that I have is the name (vstack or tstack, t=true?), but without a library for working with sets -and with join as the set union but preserving duplicates and disorder- don't know if it is 'avaible' or not.

About the other thing: For 'proffesional' answer I meaning that one needs the help of the function more than the code to know what's is answering the function. Also that follow some kind of rules, like that other answers from other functions are similar in structure, as opposite to answers ad hoc. In that sense there are not to much functions that returns nested arrays in mathcad.

Nice job.

Regards. Alvaro.
Top Tags