LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re: repeatability of words in an array

I have a 2D array where Row 1 contains frequencies and Row 2 contains their corresponding amplitudes. When I separate these into 1D arrays, convert them into strings, and pass them through your code individually, the frequencies and amplitudes do not align correctly in the final output.

For example, the frequency 99M should have an amplitude of -100.2, but the final output incorrectly shows it with an amplitude of -99.2, which actually corresponds to 104M. This misalignment occurs because both frequencies (99M and 104M) have the same number of occurrences (once). The frequencies and amplitudes aren't properly aligned in the final output when they have the same number of occurrences.

I've attached the code where frequencies and amplitudes are handled as separate arrays, though they originate from a 2D array. I would like to use your code to correctly pair frequencies with their respective amplitudes and display the number of occurrences in the output. Can you guide me on how to achieve this desired result?

0 Kudos
Message 1 of 24
(786 Views)

Hi qureshi,

 


@qureshi000 wrote:

I've attached the code where frequencies and amplitudes are handled as separate arrays, though they originate from a 2D array. I would like to use your code to correctly pair frequencies with their respective amplitudes and display the number of occurrences in the output. Can you guide me on how to achieve this desired result?


You don't want to count words, but create a histogram of your XY pairs.

That's a huge difference and so you cannot use an algorithm that counts occurances of your X and Y data separately!

 

As a hint on how to go forward:

Btw. LabVIEW comes with histogram functions…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 24
(780 Views)

I do not understand your hint. Please explain it.

0 Kudos
Message 3 of 24
(743 Views)

Hi qureshi,

 

for your data analysis you need to keep your XY pairs instead of sorting each X and Y array separately. How to create and sort an array of XY pairs is shown in my message.

 

Now you can easily count identical X values and analyze their corresponding Y values…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 24
(739 Views)

Currently it is a recorded data but in real-time at same frequency a different amplitude can be arrived. Similarly, more than one frequency can have same amplitude. I also have to cater that situation.

0 Kudos
Message 5 of 24
(726 Views)

When I combine X and Y to keep XY as a pair (using index and bundle cluster array.vi) your further code is based on data type string. So, it gives me datatype mismatch error because XY pair is 1D array of cluster of 2 elements. How can I deal with this issue?
Pairing of XY is shown in the attach picture.

qureshi000_0-1725452499606.pngqureshi000_1-1725452538709.png

 

0 Kudos
Message 6 of 24
(693 Views)

Hi qureshi,

 


@qureshi000 wrote:

When I combine X and Y to keep XY as a pair (using index and bundle cluster array.vi) your further code is based on data type string. So, it gives me datatype mismatch error because XY pair is 1D array of cluster of 2 elements. How can I deal with this issue?


My code isn't string-based.

That old code in the thread you originally hijacked was string-based.

 

Why do you want to go the "string datatype" way when you need/want to handle numeric data?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 24
(689 Views)

I combined X (frequencies) and Y (amplitudes) to keep XY as a pair (using index and bundle cluster array.vi). Now I want output which contains Frequencies with their respective amplitudes and No of occurrences based on frequencies. How can I achieve it? Kindly guide me.

0 Kudos
Message 8 of 24
(665 Views)

I really don't understand what you are trying to accomplish.

With this input:

paul_a_cardinale_0-1725514437368.png

what would you want the output to be?

paul_a_cardinale_1-1725514458786.png

 

 

0 Kudos
Message 9 of 24
(660 Views)

Last amplitude as shown in attached picture.

qureshi000_0-1725516796500.png

 

0 Kudos
Message 10 of 24
(648 Views)