Jump to content
liakofan

extracting information about specific array element

Recommended Posts

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="">

Share this post


Link to post
Share on other sites

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

  • Like 1

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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 by crossrulz

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

@ 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.

post-13461-0-51813900-1290627584_thumb.p

Share this post


Link to post
Share on other sites

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 by crossrulz

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 by crossrulz

Share this post


Link to post
Share on other sites

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.

post-11268-0-31965700-1291038106_thumb.p

Edited by crossrulz

Share this post


Link to post
Share on other sites

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.

post-11268-0-31965700-1291038106_thumb.p

That's a good point, the XOR is actually unnecessary. All in all, pretty slick.

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites

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.

post-18391-0-38927900-1291110677_thumb.j

Edited by liakofan

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.