LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

split 2D array by Rows and Columns with condition

Solved!
Go to solution

Hi Guys, 

 

I need a help with something might be silly but i can't make my head over it. 

 

i initialized a 2D array with 10 rows and 16 columns. connected to Replaces array subset, and the new element that feed the RAS is coming from Spreadsheet String to Array (which read the real time data from VISA). 

 

I need to split my 2D array to be 2 1D arrays, one for rows and the other for columns.

 

I'm using Arduino to collect my data from sensor sheet. however, in my code i insert two specific lines which is going to be the starter of each Row and Columns. 

 

I need to detect number 2000 in the beginning and since i detect the 2000 i'll insert the data into 1D array of the rows for 10 times. 

then i need to detect number 5000 and when it's true, i should insert my data into 1D array of the columns for 16 times. 

 

I tried index array and reshape array, but still something missing from me. 

I tried to compare my new element with the number 2000, then tried to index it in an array but i couldn't solve the idea that the comparison is Boolean and i'm dealing with arrays. so i had always broken arrows. 

 

any idea could help me please. 

 

 

 

 

please check the attached documents. 

Download All
0 Kudos
Message 1 of 17
(5,544 Views)

Hi N.,

 

like in all your other threads your "explanations" are rather "uncommon" (misleading/hard to understand)…

 

Why don't you show some before/after examples? What are your input data and how should the output data look like?

 

i initialized a 2D array with 10 rows and 16 columns. … I need to split my 2D array to be 2 1D arrays, one for rows and the other for columns.

You have an 2D array with 10×16 elements. Which of them should go to your "rows" 1D array and which ones to the "columns" array?

Which row/column to you want to select?

Usually you need to use IndexArray to read rows or columns from a 2D array!

 

I need to detect number 2000 in the beginning and since i detect the 2000 i'll insert the data into 1D array of the rows for 10 times. 

IF first element in row == 2000 THEN append row to 1D array 10 times

then i need to detect number 5000 and when it's true, i should insert my data into 1D array of the columns for 16 times. 

You need basically the same code as for the "2000" detection - I think I don't need to repeat that pseudocode…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 17
(5,527 Views)

Here's the snippet I created to read the txt file you provided in a previous thread. As you can see, there are a couple of minor (but probably vitally important) changes. Since I had some data, it was easier to see which way should be which 🙂

 

  • The QR function is wired with a 10, not a 16 - as you highlight here, the data repeats every 10 readings.
  • The RAS replaces a Row, not a Column, as I had previously guessed mistakenly.
  • There is no handling for the 2000, 5000 here - these are interesting for debugging, but will only complicate your actual processing.
  • The (previously) empty line between blocks is dropped by a For loop before the main loop. This won't be so easy for the VISA read, because the goal is to prevent 'i' increasing. You can either remove the empty PrintLn() function call, or add a shift register with a numeric type (like U32) and just increment when the line isn't empty.
  • I added a Wait in case structure to load the data one block at a time, then pause for 1s. You should of course remove this for real reads.

 

ReadSerialPressureData_BD.png

 

You should be able to use this in your VISA version to process the output. Be careful for the empty line, which will mess with the positioning (an alternative is to change the 10 to 11 in QR function, and do nothing when the remainder is 10 (similar to the varied wait case).


GCentral
0 Kudos
Message 3 of 17
(5,514 Views)

Gerd, 

 

thanks for replying. 

 

first of all, i'm not native English speaker. so excuse me for misleading. 

 

simply i want to represent my data that i'm receiving from Arduino over the intensity graph, frame by frame. 

 

however, the idea of the numbers 2000 and 5000 wasn't efficient. 

 

but please check the output from placing my palm (hand) over this sheet / you have a pic of labview output and the data from Arduino serial monitor. 

 

 

 

thank you. 

Download All
0 Kudos
Message 4 of 17
(5,499 Views)

hi Cbutcher,

 

  • There is no handling for the 2000, 5000 here - these are interesting for debugging, but will only complicate your actual processing.

that is totally true, and i discard the idea after i learned the hard way. 

 

You can either remove the empty PrintLn() function call, or add a shift register with a numeric type (like U32) and just increment when the line isn't empty.

 

that is not an option cause i need to know exactly what happened in each individual sensor. 

 

 

 

please check my reply on the post of Gerd, it represents my output data. 

 

all what  i need is represent my data similar to my real time input. 

assuming i'm placing my hand, i just want to see something represent the hand 😞 

 

 

 

thanks for your helping and advising all the time mate. 

0 Kudos
Message 5 of 17
(5,496 Views)

Hi N.,

 

your text file seems to contain blocks of 2D data, seperated by an empty line.

Each block seem to correspond to one "frame" you are talking about…

 

Read the text file, split at empty lines, convert each block of data ("frame") into a 2D array, display this 2D array in the intensity graph.

What exactly is your problem, when you try to follow those steps?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 17
(5,486 Views)

Hi Gerd,

 

that is exactly as you said. 

 

and this is what i'm doing, but when it came to be displayed over the graph, it doesn't give me the shape of the data and the location. 

 

assuming i placed my phone which is rectangular on the top left side of the sheet, it won't be displayed with shape and location. 

 

you'll find something on the intensity graph as the previous attached picture in my earlier reply. but unable to detect that object (no correct position or shape). 

 

that is simply what makes me frustrated. somehow the indexing in the graph is not correct , not quite sure mate. 

 

 

 

Regards,

0 Kudos
Message 7 of 17
(5,483 Views)

Gerd, 

 

if my VI doesn't fit with the same idea you just mentioned, can you tell me how to correct it. 

this is the only subvi with problem from my whole big VI. 

 

the rest of my software working properly. 

 

the attached picture is my original VI for this aspect. 

0 Kudos
Message 8 of 17
(5,481 Views)

First time I've tried to upload video so apologies if it's useless - the link is https://youtu.be/1P-e0kD25tA

Is this what you got, more or less? This is generated from the text file you uploaded.


GCentral
0 Kudos
Message 9 of 17
(5,454 Views)

that is awesome. 

 

yes it's more or less the same, except it's keep shifting all the time. 

 

I tried to read my uploaded data on this form, and more or less is the same. 

 

on real time always keep shifting and not in the position, that's why i'm trying to figure out how to do it similar to your way, keep it in their position without the shift.

 

i'm so confused now

 

 

 

Thanks mate

0 Kudos
Message 10 of 17
(5,449 Views)