취소
다음에 대한 결과 표시 
다음에 대한 검색 
다음을 의미합니까? 

How do you subtract different values for specific array elements?

해결 완료!
솔루션으로 이동

Hi LabVIEW Community,

 

I am new to LabVIEW and Im working on my first application. One of my challenges that I am having problems solving is how to  subtract specific values from specific elements in an array.

 

My aplication is to measure the distance between a sensor and a magnet, however the initial distance for each sensor  to magnet is different. I have converted the voltage to a distance using the Math Node for each element and now need to  correct these values by subtracting their individual initial value.

 

The source is a 1D array of DBL64  consisting of 32 elements and each of these values needs to have a different value subtracted.

 

eg:

Element 1 - 5.557

element 2  - 2,34

element 3 - 7,654  and so on

 

I have tried to seperate (index the array) and subtract the values from each element and then combine them again. This has not been effetive. I need to write these values to an .txt file and also use them in another calculation.

 

I have attached my attemted sub VI.

 

Any advise would be really apprecieated.

 

 

 

 

0 포인트
1/8 메시지
4,559 조회수

Could you please upload your VI again for LV12?

thanks.


0 포인트
2/8 메시지
4,555 조회수

Hello ectoxmussel,

 

The numeric operator primitives are polymorphic and can operate on your arrays element-by-element if you provide two arrays containing the operands.

 

It's simple once you know that it works, but if you don't read the help for the primitives it can be overlooked pretty easily - I've definitely been surprised in the past by things like this that "just work"!

 

Untitled.jpg

 

Hope that helps! 

Tom L.
0 포인트
3/8 메시지
4,554 조회수

Thanks for the quick reply,

 

Here is the Sub VI in LV12

0 포인트
4/8 메시지
4,542 조회수
솔루션
주제 작성자 ecotoxmussel이(가) 승인함

You don't need to overthink it. There's a really simple method. Generate an array that contains all your offsets you want.  Then subtract it off.

 

It's the same VI with this change:

 

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

5/8 메시지
4,524 조회수

Hi Tom L.

 

Thanks for your quick reply. I will have to look at it again when I go back to uni tomorrow.

 

Cheers,

 

0 포인트
6/8 메시지
4,511 조회수

Hi bsvare

 

Thank you for your help and advise. As an ecology student there seems to be no simple methods:).
I will run the modified VI tomorrow when I return to uni.

0 포인트
7/8 메시지
4,507 조회수

Thank you for your help. My program is now running and I am collecting data. It was an easy solution but it just never came to mind.

 

Cheers once again for your time bsvare!

 

0 포인트
8/8 메시지
4,477 조회수