09-03-2024 11:51 PM
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?
09-04-2024 12:42 AM - edited 09-04-2024 12:43 AM
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…
09-04-2024 02:23 AM
I do not understand your hint. Please explain it.
09-04-2024 02:27 AM
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…
09-04-2024 04:11 AM - edited 09-04-2024 04:13 AM
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.
09-04-2024 07:22 AM
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.
09-04-2024 07:36 AM
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?
09-05-2024 12:14 AM
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.
09-05-2024 12:33 AM - edited 09-05-2024 12:34 AM
I really don't understand what you are trying to accomplish.
With this input:
what would you want the output to be?
09-05-2024 01:15 AM
Last amplitude as shown in attached picture.