11-17-2021 10:18 AM
Hello,
I am measuring real and imaginary part of scattering parameters in Vector network analyzer. The analyzer is giving two data points (real and imaginary) at each sweep point (frequency) in a form of 1D array. The real and imaginary part are intermixed in the array- the first element is real and the second one is imaginary and so on .. I want to split this array into two arrays with alternating elements. Can anyone help me how to do it?
Thanks in advance!
Solved! Go to Solution.
11-17-2021 10:26 AM
Decimate 1D array is exactly what you need, feed in the 1D array, resize the function to output two 1D arrays
11-17-2021 10:27 AM
Simply use the "Decimate 1D Array" function.
11-17-2021 10:35 AM
Did you know that "decimate" originally meant to kill one out of every ten in a group as a group punishment?
11-17-2021 10:37 AM - edited 11-17-2021 10:58 AM
I would typecast it to a complex array instead. Now you only have one array. 😄
I assume that most further processing will operate on complex datatypes anyway. 😄
(Of course you need to adjust the array constant according to the input, for example if the input is SGL, it would need to be CSG, etc. If the input array is integer, you should probably convert it to floating point first.)
My gut feeling is that the typecast solution will be more efficient, because there is no change in memory order of the elements. If you decimate, you create two separate 1D arrays of half size, just to interlace them again into the complex array. Array data is always contiguous in memory, so unless the compiler can see through all that, more allocations are needed for this route.
11-17-2021 11:11 AM
@Bill - could you please elaborate on your observation of decimate 1D?
@Altenbach - that is an excellent way, new learning about TypeCast and complex numbers.
11-17-2021 11:15 AM
It's in the etymology of the word. Thankfully, the decimate array doesn't kill people (not directly, anyway); it just sorts elements in an array like a card dealer deals a poker hand and you end up with an "array" of cards.
11-17-2021 11:18 AM
Hello guys,
Thank you very much for your help. I truly appreciate your prompt replies.
Both solutions work well. I need both the real and imaginary parts but separately for further analysis.
Thanks!
11-17-2021 12:05 PM - edited 11-17-2021 12:17 PM
@LabSky wrote:
Both solutions work well. I need both the real and imaginary parts but separately for further analysis.
Can you tell us a bit more about that "further analysis".
It is likely that everything can be done much more efficiently directly with complex data, for example most transforms (e.g. FFT) understand complex inputs. Even simpler things such as magnitude and phase are easy to obtain without need of any trigonometry functions. 😄
Scaling and rotation in the complex plane (e.g. for phase correction) is just a multiplication with a complex scalar of given R and theta and if r=1, it's just a rotation (example).
Even xy graphs understand complex arrays directly and will graph IM vs RE!
(this is only the tip of the iceberg!)
11-18-2021 03:02 AM
@altenbach I am measuring an absorption curve which is proportional to the imaginary part of susceptibility tensor. To be honest we only care about imaginary part. But for the completeness we do also measure the real part.
The vector network analyzer is very sophisticated instruments although. It allows to measure the magnitude, phase, and delay separately.
Your suggestion is indeed the best for the handling and post processing of complex data sets.