LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array subtraction returns 0 value

Hi,  

 

I am writing a code to take spectrum from a spectrometer, and I want to have the option of with/without background subtraction.

And I set the array to be all 0 when I choose no background subtraction, then the final spectrum shows all 0.  

By monitoring the data, I found it is the 'minus' function that cause the result.  It returns an array with all 0 when subtracted the  background (all 0 values) from a signal (not all 0). 

I simulated the singal using random numbers (with code attached), but the idea is the same.

Can you help me find a solution on this?

 

Thanks

 

0 Kudos
Message 1 of 7
(2,738 Views)

Your are using an array of size sero when you aren't subtracting the background. The array needs to be the same size. Better yet though would simply not do the subtraction when the background should not be removed.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 7
(2,733 Views)

Hi Mark, 

Thanks for the reply. I am not familiar with LabVIEW.  How do I set the size of the array? By initialize?

I also want to ignore the background subtraction when it is not needed, but how can I bypass it?

Thanks

 

0 Kudos
Message 3 of 7
(2,730 Views)

To ignore the background subtraction, you can use a case structure. i.e. 'TRUE' = subtraction case, 'FALSE' = no subtraction case. 

0 Kudos
Message 4 of 7
(2,715 Views)

Just use a case structure.

The False case only has the wire from the Signal tunnel to the Final Spectrum tunnel (passing straight through).


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 5 of 7
(2,710 Views)

Alternatively, you could build an array with zeroes instead of the random numbers.

 

Also:

  • Your array building is better done using autoindexing (you also have a lot of type mismatches).
  • Since your points are equally spaced in x, you don't need an xy graph and the associated more complex data structures. A plain waveform graph is sufficient.
  • There is a primitive to take the mean of an array.

 

Maybe the attached can give you some ideas.

0 Kudos
Message 6 of 7
(2,700 Views)

Hi, 

Thank all of you guys, this is very helpful. 

0 Kudos
Message 7 of 7
(2,689 Views)