Hi,
I am using a Macro that gets the values from tables (results or a user-created table) and I need to replace NaNs with zero for the next step in the macro to work (Array.findMaxima), but every method I have tried for replacing NaNs runs into bugs. I have tried converting the table to arrays or new tables, but even if the ‘NaN’ gets replaced as a 0 and I use the parseFloat command to specify that the 0 is a number, it is still somehow not recognized as such; ie. the parseFloat command doesn’t seem to work for array or table elements (tho it does work for strings). Who should I ask to address this bug or does someone know any other ways to do this that actually work? (Please test first, as many things that should work don’t seem to.)
I found a work-around that seems to work on Windows 10 PCs. It converts each line of the results table to a string, replaces NaNs with 0 and then creates an array from the string. I feel like there should be a better way to do this.
for (row=0; row<nResults; row++) {
line = “”;
line = line + getResult(“Mean”,row);
meanNum=parseFloat(line);
if (line.contains(NaN)){
line=0;}
meanNum=parseFloat(line);
if (row== 0) {
meanNumArray=meanNum;}
if (row>0){
meanNumArray= Array.concat(meanNumArray, meanNum);}}
maxSlice=Array.findMaxima(meanNumArray, 0);
Thanks!