matlabsignal-processingtelecommunication

Error: using abs Complex integers are not supported


I get class:int16 type data using "audioread(filename, 'native')", which is a data IQIQIQ... stream. Then, I use complex(I, Q) to form the complex data samples. When I do abs(complex(I, Q)) to get the sample amplitude, I get an error: "Error: using abs Complex integers are not supported". Any advice on how to solve this problem?


Solution

  • Casting complex(I,Q) as double before calling abs() may be an option. Then the result can be re-casted as type int16. I believe the abs() function expects a double, complex double or single as input to compute the magnitude. Since the data is complex the only types allowed are singles and doubles. Assuming you're looking for the magnitude of the complex data this may suffice. If you're looking to just take the absolute of the components calling abs() on channels/vectors I and Q before calling complex() may be an option.

    Casting as Type single

    Audio = audioread("TETRA IQ.wav",'native');
    I = Audio(:,1);
    Q = Audio(:,2);
    
    Complex_Pair = complex(I,Q);
    Complex_Pair_Double = single(Complex_Pair);
    Magnitude = uint16(abs(Complex_Pair_Double));
    

    Casting as Type double

    Audio = audioread("TETRA IQ.wav",'native');
    I = Audio(:,1);
    Q = Audio(:,2);
    
    Complex_Pair = complex(I,Q);
    Complex_Pair_Double = double(Complex_Pair);
    Magnitude = uint16(abs(Complex_Pair_Double));
    

    Ran using MATLAB R2019b