LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arrays of different lenghs and Nans

Solved!
Go to solution

Hi guys

I have some arrays of different lengh that I want to save to files.

So, a simple structure like this

nitad54449_0-1692476838451.png

works fine, if the lenghts of arays X and Y ae the same. 

If there are not , like here

 

nitad54449_1-1692476939590.png

 

we'll get only the 2 lines. This is normal, but I would like to get this result

nitad54449_2-1692477030314.png

 

I could do that by inspecting each array length and filling the shortest array with Nan's but I have some clusters of arrays as input and looking for a better alternaive, if any.

Thanks

0 Kudos
Message 1 of 8
(1,228 Views)

A FOR loop will only iterate as many times as the shortest autoindexing input array (or value wired to N). You can pad the shorter array with NaNs before the loop. Do you always know which one is shorter?

 

You could also build them into a 2D array (which will pad with zeroes) and use array to spreadsheet string.

 


@nitad54449 wrote:

I could do that by inspecting each array length and filling the shortest array with Nan's but I have some clusters of arrays as input and looking for a better alternaive,


 

If you have more complicated data structures, please show them as example. (... and please attach your VI containing typical default data instead of just pictures!)

0 Kudos
Message 2 of 8
(1,199 Views)

Hi Christian

Thanks for your input. I have an AE for saving data the way I want... I send commands to create files, send clusters of arrays to save, text or time, then close the file.

For the program I am working on, I want specifically to save Nan to indicate that the data is not available (I don' want 0, as 0 can be a measurement data).

Typically the first array in the cluster is the biggest one.

Regards

 

Download All
0 Kudos
Message 3 of 8
(1,183 Views)
Solution
Accepted by topic author nitad54449

Here's what I might do for all the various cluster save operations (example for cluster of four 1D arrays, but easy to expand). It does not matter which cluster elements has the most elements.

 

altenbach_0-1692490871575.png

 

Message 4 of 8
(1,160 Views)

thanks,

much better..

didn't know the +Nan thing, but it's logic though.. if you add a number witth a non-number.. what do you get ?

thanks again, Sir 🙂

N

0 Kudos
Message 5 of 8
(1,140 Views)

nvm I'm late with my solution.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 8
(1,114 Views)

Note that my code is focused on simplicity and lean code. Other more literal "solutions" would involve measuring the length of each 1D array and find the max, then initialze a 2D array of NaNs or calculate how many NaNs needed to be appended to each 1D array. My solution does not need anything blue or any convoluted code, not even a FOR loop. 😄

 

More complicated code always has more places for potential bugs to hide. 😄

0 Kudos
Message 7 of 8
(1,057 Views)

Hi

Thanks, I got it. it work ok !

N

0 Kudos
Message 8 of 8
(1,042 Views)