문제

hello this question may seem stupid but i'm new to any sort of programming. I just did the fourier transform (using a subroutine provided to me) of a data and got the values in complex format , which looks like this:

(-1.6391770E-08,-0.3750000) (1.6391770E-08,0.3750000) ..............etc

i saved these format in a dat file. Now i need to calculate the phase angle of this data, i tried to use 'atan2(y,x)' intrinsic function but it needs real and imaginary data as x and y separately. I don't know how to extract these x and y from the complex format of above. I tried to use open and read function but it didn't work as there was bracket before and after the data in dat file. Am i missing something here? I need to find out the phase of the fft data. Thanks in advance for the help and sorry if my question is vague, if so i will try to make it clear.

도움이 되었습니까?

해결책

It's not entirely clear what your problem is, or perhaps you have several problems. If you have a complex variable called, say, z, then you can pass its real and imaginary components to atan2 with a call such as

atan2(aimag(z),real(z))

The functions real and aimag extract the components of a complex number. If you are working with non-default kinds then these functions also understand kinds, so a call such as real(z,real64) will, if real64 is a kind-type parameter, extract the real component of z with real64 kind.

Note that these functions are both elemental which means that they can be applied to each element of an array and return an array of elements; so a call such as

real(z_array)

will return an array of reals with the same shape as z_array.

It looks to me as if you should be able to read the complex values directly from the file and then decompose them for your calls to atan2.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top