Effective method to test matrix columns<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hello all ,
I have a matrix with 5 columns . I want to filter the matrices for a specific condition so lets say MinValue = 20 and the name of my matrix is Data .
How can I filter the values in each column using the MinValue and replace everything which fails the condition with NULL . How can I do it if I were to do it for the entire matrix and specifically for one or more columns ?
For Eg :
Col1 Col2 Col3 Col4 Col5
50 2 60 40 10
10 10 10 10 10
21 22 23 19 24
Output should be
Col1 Col2 Col3 Col4 Col5
50 NULL 60 40 NULL
NULL NULL NULL NULL NULL
21 22 23 NULL 24
I dont want to use loops if there is a possibility .
Regards
Uday
Re: Effective method to test matrix columnsThe loc() function is returning a vector of positions (locations) in the matrix where the value is less than 20. Then I am using the vector of positions as a subscript to the matrix and assigning a missing value (the period) to those positions in the matrix.
Re: Effective method to test matrix columnsHello Michael ,
How does that replace the selected data with NULLS ?
Uday
Re: Effective method to test matrix columnsIf I'm understanding your question correctly, the loc() function in JSL should help:
minValue = 20;
data = [
50 2 60 40 10,
10 10 10 10 10,
21 22 23 19 24];
data[loc(data<20)] = .;
show(data);