我如何在Matlab上旋转绘图?

问题描述 投票:0回答:1

我想旋转此处所示的曲线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)
matlab plot rotation
1个回答
0
投票

我结合了两个建议来创建以下代码。

h = findobj(gca,'Type','line');
x_org=get(h,'Xdata');
y_org=get(h,'Ydata');
points = [x_org; y_org]';

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

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

将其添加到代码的末尾将导致下图:enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.