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

How to create a custom array?

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

I would like to built a custom array containing numbers from 0 to 128, I have already done that using a FOR loop and autoindexing. Now I'd like to append eight zero's after every 8 elements, so my new array would look like: 0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0,8,9,10,11,12,13,14,15,0,0,0,0,0,0,0,0,16,19, .... and so on. How can this be implemented? 

 

I tried using insert into array and build array functions, but I can't seem to figure it out. 

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

Not sure how much smaller Altenbach can make it...

 

snip.png

2/11 메시지
2,543 조회수

Not smaller, but I don't use Build Array inside For loop.

PinguX_0-1721304828594.png

 

3/11 메시지
2,513 조회수

Thank you ! 

Additionally, could you recommend some resources (free) to learn logic building for LabVIEW specifically? I have a difficult time trying to make things on LabVIEW which I can easily code in text based languages such as C++/python.

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

Hi Zain,

 


@ZainAli02 wrote:

could you recommend some resources (free) to learn logic building for LabVIEW specifically? I have a difficult time trying to make things on LabVIEW which I can easily code in text based languages such as C++/python.


The "logic" is always the same!

 

LabVIEW doesn't need "variables", you use wires instead… (THINK DATAFLOW!)

Best regards,
GerdW


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

Does your initial array have 128 or 129(!) elements?  You said "from 0 to 128", which suggests you have a 128-element array [0, 1, ..., 126, 127] and add on a singleton 128.

 

I'm going to assume your original Array had 128 elements, so goes from 0 to 127.  I would handle this problem in a different way that uses no loops at all, but treats the Array as an "array" and does "array manipulation" to get your solution (that's the "mathematician" hat I'm currently wearing).  Here are the steps (verbally -- carrying them out will be a nice "teaching/learning" exercise).

  • Transform the 1D 128-element Array into a 2D 16x8 (16 rows of 8 elements) Array.  Row 0 should be 0..7.
  • Create (without using loops) a similar size Array of all 0's.
  • Concatenate the two Arrays to get a 16x16 Array (Row 0 now is 0..7, 0, 0, 0, 0, 0, 0, 0, 0).
  • Transform the 2D 256-element Array into a 1D 256-element Array.

So I wrote down these steps, but before pressing "Post", I decided to try it.  Oops, there's a "feature" that I forgot about, but there are work-arounds.  [It is simple enough to put some Array Indicators at output points to make sure you are doing what you think you are doing].

 

So my version of this "teaches" you some useful "Array-manipulation" functions that (if you use arrays much) will come in handy.  Enjoy the puzzle.

 

Bob Schor

 

6/11 메시지
2,477 조회수

@ZainAli02 wrote:

Additionally, could you recommend some resources (free) to learn logic building for LabVIEW specifically? I have a difficult time trying to make things on LabVIEW which I can easily code in text based languages such as C++/python.


Just wait until you get to (advanced) threading situations. You'll realize you don't have to worry at all about data integrity (and the related deadlocks\livelocks).

 

Or nD arrays (although n>2 is a code smell)...

7/11 메시지
2,443 조회수
솔루션
승인자 ZainAli02

Two flat loops tend to scale better than two stacked loops.

 

altenbach_0-1721313457512.png

 

(Not sure what to do with the "128" you seem to want, so adjust as needed)

 

 

 

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


The "logic" is always the same!

 

LabVIEW doesn't need "variables", you use wires instead… (THINK DATAFLOW!)


I am just a few months old into LabVIEW, could you point in any directions that could help me? 

0 포인트
9/11 메시지
2,362 조회수

 


@Bob_Schor wrote:

 

So my version of this "teaches" you some useful "Array-manipulation" functions that (if you use arrays much) will come in handy.  Enjoy the puzzle.

 

 


Thank you Sir for this. It'll definitely help me in the longer run and I will surely give this some time to figure it out and implement it. The array is meant to be 128 elements, so from o to 127, that was a mistake on my end. 😅

0 포인트
10/11 메시지
2,361 조회수