rdolinar Posted September 21, 2011 Share Posted September 21, 2011 Hi I have a problem with some discrete signals logging.. i'm logging 5 values (1xreal and 4xbit) every couple of seconds to a *.csv file and every once in a while the last three are not logged - maybe just one value, maybe two values.. this happens quite often, see attachment nr.1! When I try to read the file I get a "NaN" wherever there was a blank space in the logging file! After trending this from the virtual channel (to which I copy the data from the file) the graph/trend looks something like the attachment nr.2! I added a sequence that "cuts off" all these NaN's but it takes quite long for it to finish (almost 10 seconds) because it's a big file (every 2s for 1day that's over 43000 logs in 5 columns..): /*x1 is a variable used as an intermmediate step for copying the data to a virtual channel. I also use it to get the number of lines in the file*/ Private lines=numrows(x1)-2 Private i=0 while (i<=lines) if (V.var1[i]>0 && (i>0)) then //this is not intended for the first record logged! V.var1[i] = V.var1[i-1] //since it was not logged I write the previous value ! ! ! endif // I do the upper for all 4 discrete variables !!! i++ //increment 1 endwhile After I inserted this piece of code I got the graph in the attachment nr.3!!! So I'm asking you, is there a quicker, simplier or better way to fix these NaN's? Thank you for reply! Link to comment Share on other sites More sharing options...
AzeoTech Posted September 21, 2011 Share Posted September 21, 2011 You are getting blanks because the data isn't lining up, possibly because there is no data at that point. If you want you can eliminate them by selecting the duplicate last value option in the logging set. However, using that option can be deceiving, because you are logging the last known value which may be old. If you want to remove it after loading the file, use the filter() function, for example: x1 = filter(x1, (x1 != 0) && (x1 != 1)) which will remove all values that aren't 1 or 0. It'll run pretty much instantaneously, even with 43000 lines. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.