取消
显示结果 
搜索替代 
您的意思是: 

Extracting First n elements of array

已解决!
转到解答

Hello,

For a program I am creating I need exactly 16384 data points of a current waveform.  This is a strange number but is a requirement for a VI from a driver for a function generator.  I have many csv files of waveforms that I would like to use.  However, some of the waveforms have more and some of them have less than this number of data points.  Therefore, if there are more data points, I want to cut off and extract only the first 16384 data points and use those.  When there are less, I want to just add zeros after the last data point until I have enough of them.  I then need to put this data back into a csv file as that is what the function generator VI takes as an input. What are some of the best ways to do this?

Thank You

0 项奖励
1 条消息(共 7 条)
5,130 次查看

Hi lucasphee,

 

to ensure exactly 2^14 elements in your array you could append 2^14 zero elements to the input array, then uase ArraySubset to take the first 2^14 elements:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 项奖励
2 条消息(共 7 条)
5,124 次查看

Hello,

I was able to figure out my question on my own but thank you for the response!

0 项奖励
3 条消息(共 7 条)
5,058 次查看

@GerdW wrote:

Hi lucasphee,

 

to ensure exactly 2^14 elements in your array you could append 2^14 zero elements to the input array, then uase ArraySubset to take the first 2^14 elements:

check.png


A reshape array would bot shrink and grow an array to that size:

Grow Shrink array.png

The 'fill value' can't be set though.

4 条消息(共 7 条)
5,033 次查看

@lucasphee wrote:

Hello,

I was able to figure out my question on my own but thank you for the response!


Others could benefit from your solution. Please post it.

 

It help if you accept a (your) solution. It keeps the forum clean...

0 项奖励
5 条消息(共 7 条)
5,032 次查看
解答
已被主题作者 lucasphee 接受

To get the first n elements all I had to do was use the Array Subset and connect the number n to the length input.  The output was the first n elements of the array.

6 条消息(共 7 条)
5,009 次查看

@lucasphee wrote:

To get the first n elements all I had to do was use the Array Subset and connect the number n to the length input.  The output was the first n elements of the array.


Thanks for posting and accepting a solution!

 

Keep in mind that this method will only shrink the array. If that is your situation, it is indeed the simplest and best solution.

0 项奖励
7 条消息(共 7 条)
5,002 次查看