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

nested iteration(?!)

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

Hello fellow programmers,
Following is the challenge I'm trying to solve:
I have 2 arrays : WL-Reference & WL-Actuatorscan. Length of WL-Actuatorscan is higher than that of WL-Reference. I'd like to iterate through WL-Reference, and for each element of that array I'd like to find all the values from WL-Actuatorscan that fall within a certain tolerance around that element of WL-Reference and then group them together.
If it was Python, I'd do something like (pseudocode):
for elementRef in WL-Reference:

     for elementActuator in WL-Actuatorscan:

           if elementActuator < elementRef + tolerance OR elementActuator > elementRef - tolerance:

               append elementActuator into a data structure

 

I'd like to do the same in LV. I've attached the project in a zip file alongside 1 set of example data files. Open the FindOptimisedMicrometerPositionOfLaserLine.vi for troubleshooting. If anyone of you have an idea, could you please fiddle around with the code and see if it works. I still consider myself a novice LV programmer, so I'd appreciate if you could add the code snippet and a little explanation with your suggestions.


Thank you so much in advance 🙂

0 포인트
1/11 메시지
2,374 조회수

I think this is what you want?

 

AutoindexCapture.PNG

========================
=== Engineer Ambiguously ===
========================
2/11 메시지
2,362 조회수

Hi,

 

I would place a bundle node after the conditional output tunnel of the inner loop as the resulting 1D arrays probably can/will have different lengths.

The output of the outer loop will change to an array of cluster of array - in LabVIEW in a 2D array all rows will have the same length!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 포인트
3/11 메시지
2,344 조회수

Thank You!
Not quite what I wanted. However, you gave me enough clue to figure out how to get what I wanted 🙂 See below

SudiptaDas_0-1703861044452.png

Happy coding y'all 🙂

0 포인트
4/11 메시지
2,274 조회수

Hi das,

 

what's the point in inserting into an empty array?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 포인트
5/11 메시지
2,260 조회수

Because it gives me a nice 2D array of reference and detected values:

SudiptaDas_0-1703876858432.png

I don't really know if that's the best way to do it. Perhaps some of my Pythonic practices are spilling over to LV codes. If you have a better idea, please play with the code; its attached. Please note that the code has compounded a fair bit by now.

0 포인트
6/11 메시지
2,235 조회수

@SudiptaDas wrote:

Because it gives me a nice 2D array of reference and detected values:

 

I don't really know if that's the best way to do it. Perhaps some of my Pythonic practices are spilling over to LV codes. If you have a better idea, please play with the code; its attached. Please note that the code has compounded a fair bit by now.


The output tunnel from the FOR loop already gives you that.  Just remove the Insert Into Array and wire the terminal directly to the FOR loop's tunnel.



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 포인트
7/11 메시지
2,223 조회수

FYI, in your pseudocode you have if elementActuator < elementRef + tolerance OR elementActuator > elementRef - tolerance

 

But your LabVIEW code is set to include the lower limit, so it is equivalent to if elementActuator < elementRef + tolerance OR elementActuator >= elementRef - tolerance

 

Maybe that's fine. But if you want to change it, right click on the In Range and Coerce node and uncheck Include lower limit.

8/11 메시지
2,215 조회수

@SudiptaDas wrote:

I don't really know if that's the best way to do it. Perhaps some of my Pythonic practices are spilling over to LV codes. If you have a better idea, please play with the code; its attached. Please note that the code has compounded a fair bit by now.


I agree that your array handling needs some serious work. Let's have a look how you read your file (only the first part shown).

 

altenbach_0-1703885396610.png

 

9/11 메시지
2,207 조회수
솔루션
주제 작성자 SudiptaDas이(가) 승인함

Here's how you could do the file reading, for example:

 

altenbach_0-1703891730545.png

 

10/11 메시지
2,190 조회수