Sparweb
Aerospace
- May 21, 2003
- 5,156
Hi,
Longtime user of Mathcad (I started at version 5). I've only recently become concerned with complex numbers. Budding interest in electrical engineering, doing Fourier analysis, etc.
Since the Fourier analysis function FFT() delivers a vector containing complex numbers, it would be nice to simply find the maximum absolute valued element of the result, its rank, and then carry on. This isn't working out for me.
To make a simple example, rather than dumping a thousand lines on the screen, I'll provide an example with just 4 complex numbers and demonstrate my problem. I've been using these as a "sanity" check for myself as well as a way to try finding solutions. Still stuck. Take 4 complex numbers like these:
0.31+0.70i
0.21-0.89i
0.36+0.02i
0.44-0.14i
These four have been entered into a Mathcad vector, named "x", and the first number is in rank "0" of the vector (Mathcad numbers its ranks starting from zero by default).
I want to find the MAXIMUM absolute valued number in the vector. Let's do this manually to see where we're going:
|0.31+0.70i| = 0.766
|0.21-0.89i| = 0.914
|0.36+0.02i| = 0.361
|0.44-0.14i| = 0.462
Now that I have done all the work, it's obvious that 0.914 is the maximum absolute value, and it comes from (0.21-0.89i) in rank 1. Now I want to be able to find this with a function, not manually. I will be doing FFT's on 1000's of samples at a time. There should be a function that can find this for me. Wouldn't it be nice if max() would do this. But no.
The function max() sifts through the complex numbers, picks whatever largest real number it can find, then whichever imaginary component it can find, and slaps them together! The User's Guide explicitly says the max(A) function finds the "Largest element in arry A. If A has complex elements, it returns the largest real part plus i times the largest imaginary part". Why would I want it to do this? It corrupts the complex number. Worse, the max() function is used in the Guide's examples for FFT functions! How many users get stumped by this? How many get the garbage from max() and don't realize it?
The result in Mathcad: max(x) = 0.44+0.70i ---this is garbage. It is not one of the four numbers in the vector.
I have tried combining the max() function with || absolute value operators but this spews out more garbage.
For instance:
|max(x)| = 0.827 --- which is just the absolute value of 0.44+0.7i if you were to work it out. more garbage.
max(|x|) = 1.329 --- no idea where that result comes from.
It may be blatantly obvious but I would gladly appreciate any suggestions.
STF
Longtime user of Mathcad (I started at version 5). I've only recently become concerned with complex numbers. Budding interest in electrical engineering, doing Fourier analysis, etc.
Since the Fourier analysis function FFT() delivers a vector containing complex numbers, it would be nice to simply find the maximum absolute valued element of the result, its rank, and then carry on. This isn't working out for me.
To make a simple example, rather than dumping a thousand lines on the screen, I'll provide an example with just 4 complex numbers and demonstrate my problem. I've been using these as a "sanity" check for myself as well as a way to try finding solutions. Still stuck. Take 4 complex numbers like these:
0.31+0.70i
0.21-0.89i
0.36+0.02i
0.44-0.14i
These four have been entered into a Mathcad vector, named "x", and the first number is in rank "0" of the vector (Mathcad numbers its ranks starting from zero by default).
I want to find the MAXIMUM absolute valued number in the vector. Let's do this manually to see where we're going:
|0.31+0.70i| = 0.766
|0.21-0.89i| = 0.914
|0.36+0.02i| = 0.361
|0.44-0.14i| = 0.462
Now that I have done all the work, it's obvious that 0.914 is the maximum absolute value, and it comes from (0.21-0.89i) in rank 1. Now I want to be able to find this with a function, not manually. I will be doing FFT's on 1000's of samples at a time. There should be a function that can find this for me. Wouldn't it be nice if max() would do this. But no.
The function max() sifts through the complex numbers, picks whatever largest real number it can find, then whichever imaginary component it can find, and slaps them together! The User's Guide explicitly says the max(A) function finds the "Largest element in arry A. If A has complex elements, it returns the largest real part plus i times the largest imaginary part". Why would I want it to do this? It corrupts the complex number. Worse, the max() function is used in the Guide's examples for FFT functions! How many users get stumped by this? How many get the garbage from max() and don't realize it?
The result in Mathcad: max(x) = 0.44+0.70i ---this is garbage. It is not one of the four numbers in the vector.
I have tried combining the max() function with || absolute value operators but this spews out more garbage.
For instance:
|max(x)| = 0.827 --- which is just the absolute value of 0.44+0.7i if you were to work it out. more garbage.
max(|x|) = 1.329 --- no idea where that result comes from.
It may be blatantly obvious but I would gladly appreciate any suggestions.
STF