Как я могу повернуть сюжет в MATLAB? - PullRequest
0 голосов
/ 20 января 2020

Я хочу повернуть сюжет scatterplot(rxSig) (показано ниже) на 8 градусов, например. (группа красных точек на фотографии) это не похоже на обычный сюжет, и я не нашел соответствующей информации для этого.

Ожидаемый результат: (с вращением)
expected result

Участок без вращения:
plot without rotation

R = 1000.0;
freq = 28*1e9;
T = 20.0;
lwd = 0.5;
F = fogpl(R,freq,T,lwd);
P = 101300.0;
W = 7.5;
G = gaspl(R,freq,T,P,W);
RR=[0.75,1.75,2.5,3];

for irr=1:length(RR)
    R = rainpl(10000,freq,RR(irr));
    L=R+F+G;
end

M = 64;                % Modulation order
k = log2(M);            % Bits per symbol
EbNoVec = (0:25)';      % Eb/No values (dB)
numSymPerFrame = 1000;



for n = 1:length(EbNoVec)
% Convert Eb/No to SNR
    snrdB = EbNoVec(n) + 10*log10(k)-L(1);
    % Reset the error and bit counters
    numErrs = 0;
    numBits = 0;

    while numErrs < 200 && numBits < 1e8

         % Generate binary data and convert to symbols
         dataIn = randi([0 1],numSymPerFrame,k);
         dataSym = bi2de(dataIn);

         % QAM modulate using 'Gray' symbol mapping
         txSig = qammod(dataSym,M);

         % Pass through AWGN channel
         rxSig = awgn(txSig,snrdB,'measured');

         % Demodulate the noisy signal
         rxSym = qamdemod(rxSig,M);
         % Convert received symbols to bits
         dataOut = de2bi(rxSym,k);

         % Calculate the number of bit errors
        nErrors = biterr(dataIn,dataOut);


        % Increment the error and bit counters
        numErrs = numErrs + nErrors;
        numBits = numBits + numSymPerFrame*k;
    end

    % Estimate the BER
    berEst(n) = numErrs/numBits;
end

berTheory = berawgn(EbNoVec,'qam',M);

semilogy(EbNoVec,berEst,'*')
hold on
semilogy(EbNoVec,berTheory)
grid
legend('Estimated BER with our attenuation function','Theoretical Matlab BER')
xlabel('Eb/No (dB)')
ylabel('Bit Error Rate')
scatterplot(rxSig)

1 Ответ

1 голос
/ 20 января 2020

Я объединил оба моих предложения, чтобы создать следующий код.

% Extract data points from current figure
h = findobj(gca,'Type','line');
x_org=get(h,'Xdata');
y_org=get(h,'Ydata');
points = [x_org; y_org]';

% to rotate 8 degree counterclockwise    
theta = 8;
% Rotation matrix
R = [cosd(theta) -sind(theta); sind(theta) cosd(theta)];

% Rotate points
points_rot = R*points';
figure(3)
plot(points_rot(1,:), points_rot(2,:), '.');

Добавление этого кода в конец кода приводит к следующему рисунку: enter image description here

...