LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add array from previous one in write to spreadsheet

Hi all,

          I am new to labview and having problems on how to sum array to eisting write to spreadsheet file. Basically, I wish to take images with the stage at different positions and to repeat this process without losing any informations. Currently, my vi is overwriting the existing files instead adding up from the previous position. I did try using an add function but the results is not I want unfortunately. Any thoughts / guidances on this ? I also have attached my vi here. Thanks in advance!

N.B: 1) This vi is only part of the entire vi
         2) For the desired path, any positive / negative ineger can be inserted if anyone wish to run the program

Cheers,

sdozai

0 Kudos
Message 1 of 10
(4,178 Views)

So, it seems that you want to append to the files instead of overwriting the files. Have you tried wiring in a true constant to the "append to file?" input of the "Write to Spreadsheet File" vi?

0 Kudos
Message 2 of 10
(4,163 Views)

Hi akovaski,

Thanks for the quick reply. I tried your suggestions but the outcome is not as what I expected and yes I wish to append files because I may wish repeat the process maybe around 20 times or up to 50. 

Cheers,

sdozai

0 Kudos
Message 3 of 10
(4,154 Views)

How is the outcome not as you expected? Are you still adding the images together? (you probably don't want to, adding those arrays together just adds together each of the individual pixel values)

 

Edit: I think when you're using the add function, what you really want to be using is a concatenation. The add function does not concatenate in labview, but you can use the "Build Array" vi, right click it and select "Concatenate Inputs".  (Though I suggest to not concatenate the images and just use the append-to-file functionality of Write-To-Spreadsheet)

add vs concat.png

Message 4 of 10
(4,112 Views)

Hi akovaski, 

Thanks for your reply. Well, I checked the array say for image 1 and when it rerun for image 1 it didn't add up as the value I expected ? Sorry for being a bit silly on this Smiley Frustrated I will try your suggestion a bit later cause I just got back from work and it a gloomy day in the UK Smiley Surprised 

Many thanks,

sdozai

0 Kudos
Message 5 of 10
(4,088 Views)

@sdozai wrote:

Thanks for your reply. Well, I checked the array say for image 1 and when it rerun for image 1 it didn't add up as the value I expected ?


Well, what did you expect?  Perhaps a good example is in order to help us understand your requirements.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 10
(4,059 Views)

Hi crossrulz (thanks for your response) and akovaski,

 

I think i made a confusion about appending file, sorry about that! What I want basically is to add new array to existing file. 

For example: the array for the first image was 1 , 2, 3, 4 and the second image is 5, 6, 7,8. When I repeat the process, it should add up as 2, 4 ,6, 8 for the first image and 10, 12 ,14, 16 for the second. If I use append file, the storage will be a problem because I may have to take more than 300 images.

Well, we had a thought on getting round this problem (not the most elegant way) by read opening the saved file and add it then save it again but this will most probably slow down the whole program. 

Many thanks,

sdozai

0 Kudos
Message 7 of 10
(4,015 Views)

@sdozai wrote:

For example: the array for the first image was 1 , 2, 3, 4 and the second image is 5, 6, 7,8. When I repeat the process, it should add up as 2, 4 ,6, 8 for the first image and 10, 12 ,14, 16 for the second. If I use append file, the storage will be a problem because I may have to take more than 300 images.


You making even less sense now.  All I see here is you doubled the values of your two images.  How is that an add?

 

Are you wanting to throw away some of your images?  If not, you will have that storage issue regardless.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 10
(4,001 Views)

Hi crossrulz,

Thanks for your quick response and yes, it can be viewed as a multiplication of two as well because I am basically just adding / sum arrays to their respective txt file. In the picture I attached, I captured for the first image and the array (1936x1216) consists of 4 and is saved to it respective .txt file (in this case it image 1.txt) and so on. After this cycle is done, I wish to repeat this process again and the stage moves back to the first position and do another round of image acquisition so after the first picture is taken, the array should add up (or multiply if you wish) to 8 and it saved on the original image 1.txt file instead of overwriting it. If what I am saying is wrong or doesn't make any sense at all then I might just redo the whole thing another way then. 

Cheers,

 

sdozai

0 Kudos
Message 9 of 10
(3,986 Views)

Well, we basically came out with this  as a solution but unsure what we did wrong at the array subset vi. By using a book as an analogy, say in position 1, the array will be saved in page 1 and moved to the next page for image 2 and further more. When the process is repeated and go back to position 1, it will add up or multiply of 2 (according to crossrulz) then move onto the next page. Can anyone help me on this ? Many thanks in advance,

Cheers,

sdozai

0 Kudos
Message 10 of 10
(3,940 Views)