liakofan Posted November 23, 2010 Report Share Posted November 23, 2010 Hello Everyone, I have a 16*16 array with some I32 values and i want to know with each iteration if there is a change in any of the elements. If the number of changes are bigger than 10 there should be a msg saying something. So i subtract my array with the previous one, using feedback node and i add the resulting array to itself. I can check if there is a value inside the last array greater than 10 but i can not figure out how to know what column and row the element is. If anyone could help I would appreciate it. I hope i explained the diagram correctly. Kind Regards<br style=""> <br style=""> Quote Link to comment
Ton Plomp Posted November 23, 2010 Report Share Posted November 23, 2010 Hello Everyone, I have a 16*16 array with some I32 values and i want to know with each iteration if there is a change in any of the elements. First step would be to XOR the old and new array. Then using a 'Not Equal to 0' node, you will get a boolean array where true means 'changed'. Then you need to check how much elements are true. You could convert it into a 0, 1 intger array, and use the sum of the array to get the number of changed elements. Ton 1 Quote Link to comment
crelf Posted November 23, 2010 Report Share Posted November 23, 2010 I hope i explained the diagram correctly. Can you upload the code? Much easier for us to comment and make suggestions if we can play with the code. Quote Link to comment
crossrulz Posted November 23, 2010 Report Share Posted November 23, 2010 (edited) I'm a little confused about what you are trying to do. Are you looking for 10 of the elements to change (as you stated) or are you looking for an element to change by more than 10 (as you described in your program)? Here's my shot at both. Hopefully this will at least point you in the right direction. Note: I used a 5x5 array to make it a little easier to play with on the front panel. Array Changes.vi Edited November 23, 2010 by crossrulz Quote Link to comment
liakofan Posted November 24, 2010 Author Report Share Posted November 24, 2010 Thank you all for your help! Got some really interesting ideas! My array will be changing every second and i would like to know which elements are changing more than 10 times. after the program has finished it should generate a report ( .CSV file ) saying that "these elements generated that many errors", or just more than 10 errors, which sounds easier. my program will run for 24 hours and after it should give the results. Probably i will have to sum the differences of my array from each iteration so at the end i will know the total sum of the changes as well. ( 2nd diagram ) I didn't know about what crossrulz did with dividing the array by the number of rows( ? ) so i thought about indexing my array into n different arrays in order to make it work. @ Ton Plomp : My brain can not understand right now your solution but shall look into that later on. my ,very ugly, code is the following. though crossrulez is pretty close to what i had in mind. thank you very much for your time. arrays.vi CheckingArrays.vi Quote Link to comment
crossrulz Posted November 24, 2010 Report Share Posted November 24, 2010 What you need to do is count how many times each index has changed. To do this, use a second array for just the number of changes. You can use nested for loops to iterate to see which elements have changed and if they did increment that element in the number of changes array. Then at the end, see which elements are greater than 10. Array Changes.vi Quote Link to comment
liakofan Posted November 24, 2010 Author Report Share Posted November 24, 2010 What you need to do is count how many times each index has changed. To do this, use a second array for just the number of changes. You can use nested for loops to iterate to see which elements have changed and if they did increment that element in the number of changes array. Then at the end, see which elements are greater than 10. Array Changes.vi you've been a great help! I am stuck on this almost 3 days now.... Don't know if I am doing something wrong but i don't get the results for the columns and the rows.... Also the array is going to change every second and it would be preferred no to have to push " update" every second. Should i just remove the event case and introduce a stacked sequence structure? Quote Link to comment
asbo Posted November 24, 2010 Report Share Posted November 24, 2010 @ Ton Plomp : My brain can not understand right now your solution but shall look into that later on. Here's Ton's implementation. It shouldn't be too much of a stretch to make it temporal, just use a SR or a feedback node. Quote Link to comment
crossrulz Posted November 24, 2010 Report Share Posted November 24, 2010 (edited) you've been a great help! I am stuck on this almost 3 days now.... Don't know if I am doing something wrong but i don't get the results for the columns and the rows.... Also the array is going to change every second and it would be preferred no to have to push " update" every second. Should i just remove the event case and introduce a stacked sequence structure? I was using the event structure as a simulation so I could see exactly what all of my data was doing when I decided that the "1 second new data" occurred. I was aiming more for the example than the actual code you should use. In reality, you should be getting new data once a second, compare it to the previous data, increment the changed array where necessary. So yeah, get rid of the event structure and replace the data control with your input data (however you are getting it) and exit the while loop however you plan on ending your test. Edited November 24, 2010 by crossrulz Quote Link to comment
stevenj0589 Posted November 25, 2010 Report Share Posted November 25, 2010 thanks got spme help here too Quote Link to comment
liakofan Posted November 28, 2010 Author Report Share Posted November 28, 2010 Would somebody please tell me why i can't convert crossrulez example so that it can work with a 16x14 array? have you customized the arrays somehow? I can not figure out what is going wrong. array16x14.vi Quote Link to comment
ShaunR Posted November 28, 2010 Report Share Posted November 28, 2010 Would somebody please tell me why i can't convert crossrulez example so that it can work with a 16x14 array? have you customized the arrays somehow? I can not figure out what is going wrong. Because his example only updates and checks when there is a change in data. Your version (without the event case) continuously evaluates the difference between the current and previous values so you miss the change. By the time you press the stop button, the previous and current values are the same (although different from the starting values) therefore you don't detect a difference. Quote Link to comment
crossrulz Posted November 29, 2010 Report Share Posted November 29, 2010 (edited) oops, I originally looked at the wrong file... Where you are falling short is the fact that the arrays need to be predefined. I put data in the locations for a 5x5 array. If you are going to a 16x14, go to element 15,13 (because it is zero based) and put a 0. Do this for the Array control, "previous array" constant, and the "number of changes" constant and you should be good. I would also add a wait to your loop just so you don't hammer your processor. @ShaunR The number of changes is constantly being updated and saved in a shift register. Therefore a value change will not be missed. Edited November 29, 2010 by crossrulz Quote Link to comment
crossrulz Posted November 29, 2010 Report Share Posted November 29, 2010 (edited) I just started thinking about Ton's method. While I don't see the point of the "XOR" and then the "Not Equal to Zero" (just use the "Not Equal"), I think he has the right idea about converting the boolean to a 0,1 and then adding. This does seem like a much simpler implementation. Edited November 29, 2010 by crossrulz Quote Link to comment
asbo Posted November 29, 2010 Report Share Posted November 29, 2010 I just started thinking about Ton's method. While I don't see the point of the "XOR" and then the "Not Equal to Zero" (just use the "Not Equal"), I think he has the right idea about converting the boolean to a 0,1 and then adding. This does seem like a much simpler implementation. That's a good point, the XOR is actually unnecessary. All in all, pretty slick. Quote Link to comment
ShaunR Posted November 29, 2010 Report Share Posted November 29, 2010 @ShaunR The number of changes is constantly being updated and saved in a shift register. Therefore a value change will not be missed. You're right. In my quick scan of the examples I assumed that identifying which ones had changed was also a requirement. If it's only the number then it should count them OK. Quote Link to comment
liakofan Posted November 30, 2010 Author Report Share Posted November 30, 2010 (edited) i believe i am in a very good path. The only thing that is missing is scanning the MoreThan10? array for elements being true because they correspond to another array from which i have to generate a file saying that these elements exceeded 10 errors and reached, this value. Edited November 30, 2010 by liakofan Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.