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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

filtering a data matrix of a particular value

WalterSchrabmai
8-Gravel

filtering a data matrix of a particular value

Dear all,

long time ago after I did programming MathCAD.

How can I filtering on DATA Matrix here for all submatrixes which have conc = 0.5 f.e.

I did this but is buggy. Maybe some one can tell me, so that I can remember my knowledge I

have forgotten. thanksimage.png

1 ACCEPTED SOLUTION

Accepted Solutions

It always would be better to attach the worksheet itself rather than just a picture.

 

The error you get is because of wrong usage of the function "matrix". The third argument of "matrix" must be a function in two arguments.

If your intention was to create a 1 x 2 row vector with two zeros, you could write

Werner_E_0-1715092220563.png

of you could use the built-in "min" function

Werner_E_1-1715092253586.png

("min" must be labelled as "function")

but the most easiest and natural approach is

Werner_E_2-1715092323231.png

or maybe even better

Werner_E_3-1715092378419.png

After fixing this first line in your program either way, it looks to me that the rest should work OK.
The way you used the argument order in the "stack" function, the 'header' (?) line with all zeros would be the last line in the matrix returned.

 

Instead of a user-written program you may use the built-in "lookup" function:

Werner_E_5-1715092802146.png

On contrary to your function, this one-liner would fail if the value "Con" is not found in the "conc" data column. You could deal with this problem by using the "try ... on error ..." statement.

Werner_E_6-1715093172796.png

Of course the return value in the error branch could be anything - an all zero matrix as in your function, or a text string or ...

 

View solution in original post

2 REPLIES 2

It always would be better to attach the worksheet itself rather than just a picture.

 

The error you get is because of wrong usage of the function "matrix". The third argument of "matrix" must be a function in two arguments.

If your intention was to create a 1 x 2 row vector with two zeros, you could write

Werner_E_0-1715092220563.png

of you could use the built-in "min" function

Werner_E_1-1715092253586.png

("min" must be labelled as "function")

but the most easiest and natural approach is

Werner_E_2-1715092323231.png

or maybe even better

Werner_E_3-1715092378419.png

After fixing this first line in your program either way, it looks to me that the rest should work OK.
The way you used the argument order in the "stack" function, the 'header' (?) line with all zeros would be the last line in the matrix returned.

 

Instead of a user-written program you may use the built-in "lookup" function:

Werner_E_5-1715092802146.png

On contrary to your function, this one-liner would fail if the value "Con" is not found in the "conc" data column. You could deal with this problem by using the "try ... on error ..." statement.

Werner_E_6-1715093172796.png

Of course the return value in the error branch could be anything - an all zero matrix as in your function, or a text string or ...

 

THANKs a LOT! You enriched my knowlegde very wide with basics. Best regards

Top Tags