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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Avoid filterNaN error if there is no NaN

DJF
16-Pearl
16-Pearl

Avoid filterNaN error if there is no NaN

I have various data sets I'm performing some analysis on. Sometimes they have blanks, sometimes not.  I can easily filter out the blanks with filterNaN.  The problem is if there are no blanks the filterNaN errors out.  So, I have to rewrite the statements for each column as to whether I need to filter or not.  I'd like one command that works whether I have blanks or not. What are my options?  Here's a simple example:

filter.jpg

Here, I want to return B = [1 2 3 4 5]^T

Prime 3.1 (and is this a bug?)

Thanks,

ACCEPTED SOLUTION

Accepted Solutions
MJG
18-Opal
18-Opal
(To:DJF)

Write a short program with "try..on error"

View solution in original post

10 REPLIES 10
ValeryOchkov
24-Ruby IV
(To:DJF)

MJG
18-Opal
18-Opal
(To:DJF)

Write a short program with "try..on error"

Fred_Kohlhepp
23-Emerald I
(To:DJF)

That's a very elegant solution.

But what if the data is paired--the rows are time sequential for example.  The solution presented does not maintain that pairing; the resulting vectors are different lengths.

The attached (much less elegant) program will maintain the row correlation of a data set while stripping out any rows with missing data.

Excellent work as always Fred.  My immediate problem did not require keeping data aligned in rows, as I was just making histograms and didn't want to eliminate rows needlessly.  However, I was toying with the idea that I'd need your solution going forward since each row of data actually aligns with a test unit.  So, I'll definitely be saving this one.  Thanks!

Fred Kohlhepp wrote:

That's a very elegant solution.

But what if the data is paired--the rows are time sequential for example.  The solution presented does not maintain that pairing; the resulting vectors are different lengths.

I may be missing the point, but filterNaN works on vectors AND matrices exactly the way you would like it to be and consequently Marks modification does so, too.

It CAN be applied to very column of a matrix separately, but if you apply it on the full matrix. every row with even just one NaN is deleted.

You're right!  (as usual.)  I had not seen that.

Fred

Fred,

I can't open your file, but I think the simplest way to maintain rows of data would be to filter before separating columns:

Fred_Kohlhepp
23-Emerald I
(To:MJG)

File is Prime 3.0.

I only have 1.0 on this machine (purchased for v15).

VladimirN
24-Ruby II
(To:MJG)

Mark,

PDF version of this worksheet can be found in attachment.

Announcements

Top Tags