Main Content

MATLAB Performance Improvements

Vector-Based Processing

Use large vectors of data to minimize the function call overhead.

MATLAB Code Generation

You can accelerate your MATLAB® algorithms by generating a MEX function using the codegen (MATLAB Coder) function. For more information, see C/C++ Code Generation.

Improved Performance with 10 GigE Interface

For radios that offer both a 1 Gigabit Ethernet (1 GigE) and a 10 Gigabit Ethernet (10 GigE) interface, you can achieve improved performance at higher sample rates by using the 10 GigE interface. To set up your device with a 10 GigE connection, use the Radio Setup wizard and select 10 Gigabit Ethernet from the dropdown in the Select Link Configuration panel.

For more information about how to improve the data transfer rate between your radio and the host, see Resolve Issues with Data Transfer Rate.

These examples show that a 10 GigE interface is required to use the comm.SDRuTransmitter and comm.SDRuReceiver System objects at sample rates in excess of 25 GHz.

1 Gig E vs 10 GigE Performance for SDRu Transmitter

This example compares the performance of the SDRu transmitter System object using a 1 Gigabit Ethernet link compared to a 10 Gigabit Ethernet link. You can use this example to check your host performance capability for transmitting data with the SDRu transmitter.

1 GigE Performance

First, create a dsp.SineWave System object for generating complex sinusoidal data.

sinGen =  dsp.SineWave(...
    Frequency=100e3, ...
    SampleRate=25e6, ...
    SamplesPerFrame=1e5, ...
    ComplexOutput=true);

Create a comm.SDRuTransmitter System object for a radio connected to the host with a 1 Gigabit Ethernet link. Set the master clock rate (MCR) to 153.6 MHz, or the highest supported MCR of your radio.

MCR = 153.6e6;
tx = comm.SDRuTransmitter( ...
    Platform='N310', ...
    IPAddress='192.168.10.2', ...
    CenterFrequency=2.45e9, ...
    MasterClockRate=MCR);

Set the number of sample rates to get data for and the number of frames to transmit for each sample rate.

InterpolationFactor = [25 12 8 5 4 3 2 1];
frames = 100;

Assign variables to save sample rate and underrun data.

SampleRate = zeros(length(InterpolationFactor),2);
UnderrunCount = zeros(length(InterpolationFactor),2);

Transmit data using the SDRu transmitter System object. Log the number of underruns at the transmitter.

for n = 1:length(InterpolationFactor)
    % Set the sample rate of the SDRu transmitter
    % by updating the interpolation factor.
    release(tx)
    tx.InterpolationFactor = InterpolationFactor(n);
    % Generate data at the correct sample rate.
    release(sinGen)
    SampleRate(n,1) = MCR/InterpolationFactor(n);
    sinGen.SampleRate = SampleRate(n,1);
    data = sinGen();
    % Transmit data and log any underruns.
    for i = 1:frames
        underrun = tx(data);
        if underrun
            UnderrunCount(n,1) = UnderrunCount(n,1)+1;
        end
    end
end

Release the hardware resources.

release(tx);

Convert the underrun data to a percentage, rounded to the nearest percentage point.

pUnderrunCount(:,1) = ...
    round(UnderrunCount(:,1)/frames*100);

Tabulate the results. With a 1 Gigabit Ethernet connection, sample rates in excess of 25 MHz cause underruns at the transmitter.

format shortG
table(SampleRate(:,1)/1e6, round(pUnderrunCount(:,1)),...
    VariableNames=["Sample Rate (MHz)","Underruns (%)"])
ans=8×2 table
    Sample Rate (MHz)    Underruns (%)
    _________________    _____________

          6.144                0      
           12.8                0      
           19.2                0      
          30.72               97      
           38.4               98      
           51.2               99      
           76.8               98      
          153.6               99      

10 GigE Performance

Create a comm.SDRuTransmitter System object for the same radio connected to the host with a 10 Gigabit Ethernet link.

tx = comm.SDRuTransmitter( ...
    Platform='N310', ...
    IPAddress='192.168.20.2', ...
    CenterFrequency=2.45e9, ...
    MasterClockRate=MCR);

Transmit data using the SDRu transmitter System object. Log the number of underruns at the transmitter.

for n = 1:length(InterpolationFactor)
    % Set the sample rate of the SDRu transmitter
    % by updating the interpolation factor.
    release(tx)
    tx.InterpolationFactor = InterpolationFactor(n);
    % Generate data at the correct sample rate.
    release(sinGen)
    SampleRate(n,2) = MCR/InterpolationFactor(n);
    sinGen.SampleRate = SampleRate(n,2);
    data = sinGen();
    % Transmit data and log any underruns.
    for i = 1:frames
        underrun = tx(data);
        if underrun
            UnderrunCount(n,2) = UnderrunCount(n,2)+1;
        end
    end
end

Release the hardware resources.

release(tx);

Convert the underrun data to a percentage, rounded to the nearest percentage point.

pUnderrunCount(:,2) = ...
    round(UnderrunCount(:,2)/frames*100);

Tabulate the results.

table(SampleRate(:,2)/1e6,pUnderrunCount(:,2), ...
    VariableNames=["Sample Rate (MHz)","Underruns (%)"])
ans=8×2 table
    Sample Rate (MHz)    Underruns (%)
    _________________    _____________

          6.144                0      
           12.8                0      
           19.2                0      
          30.72                2      
           38.4                7      
           51.2                3      
           76.8               18      
          153.6               31      

Compare Performance

Plot the results to compare the performance of the 1 GigE link with the 10 GigE link. A 10 Gigabit Ethernet link is required to transmit data at sample rates in excess of 25 MHz. At samples rates in the range 25 MHz to 153.6 MHz, performance is limited by the capability of the host.

sampleRate_MHz = SampleRate/1e6;
plot(sampleRate_MHz,UnderrunCount,'-o')
grid on
xlabel("Sample Rate (MHz)")
ylabel("Underruns (%)")
legend("1 GigE","10 GigE")

Figure contains an axes object. The axes object with xlabel Sample Rate (MHz), ylabel Underruns (%) contains 2 objects of type line. These objects represent 1 GigE, 10 GigE.

1 GigE vs 10 GigE Performance for SDRu Receiver

This example compares the performance of the SDRu receiver System object using a 1 Gigabit Ethernet link compared to a 10 Gigabit Ethernet link. You can use this example to check your host performance capability for receiving data with the SDRu receiver.

1 GigE Performance

Create a comm.SDRuReceiver System object for a radio connected to the host with a 1 Gigabit Ethernet link. Set the master clock rate (MCR) to 153.6 MHz, or the highest supported MCR of your radio.

MCR = 153.6e6;
rx = comm.SDRuReceiver( ...
    Platform='N310', ...
    IPAddress='192.168.10.2', ...
    CenterFrequency=2.45e9, ...
    MasterClockRate=MCR, ...
    OutputDataType='double', ...
    SamplesPerFrame=1e5);

Set the decimation factors to get data for. The sample rate of the radio is the MCR divided by the decimation factor. Additionally, set the number of frames to receive at each sample rate.

DecimationFactor = [25 12 8 5 4 3 2 1];
frames = 1000;

Assign variables to save sample rate and overrun data.

SampleRate = zeros(length(DecimationFactor),2);
OverrunCount = zeros(length(DecimationFactor),2);

Receive data using the SDRu receiver System object. Log the number of overruns at the receiver. This can take several minutes.

for n = 1:length(DecimationFactor)
    % Set the sample rate of the SDRu receiver
    % by updating the decimation factor.
    release(rx)
    rx.DecimationFactor = DecimationFactor(n);
    SampleRate(n,1) = MCR/DecimationFactor(n);
    % Receive data and log any overruns.
    for i = 1:frames
        [~,~,overrun] = rx();
        if overrun
            OverrunCount(n,1) = ...
                OverrunCount(n,1)+1;
        end
    end
end

Release the hardware resources.

release(rx);

Convert the overrun data to a percentage, rounded to the nearest percentage point.

pOverrunCount(:,1) = ...
    round(OverrunCount(:,1)/frames*100);

Tabulate the results. With a 1 Gigabit Ethernet connection, sample rates in excess of 25 MHz cause overruns at the receiver.

format shortG
table(SampleRate(:,1)/1e6,pOverrunCount(:,1), ...
    VariableNames=["Sample Rate (MHz)","Overruns (%)"])
ans=8×2 table
    Sample Rate (MHz)    Overruns (%)
    _________________    ____________

          6.144                0     
           12.8                0     
           19.2                0     
          30.72               50     
           38.4              100     
           51.2              100     
           76.8              100     
          153.6              100     

10 GigE Performance

Create a comm.SDRuReceiver System object for the same radio connected to the host with a 10 Gigabit Ethernet link.

rx = comm.SDRuReceiver( ...
    Platform='N310', ...
    IPAddress='192.168.20.2', ...
    CenterFrequency=2.45e9, ...
    MasterClockRate=MCR);

Receive data using the SDRu receiver System object. Log the number of overruns at the receiver.

for n = 1:length(DecimationFactor)
    % Set the sample rate of the SDRu receiver
    % by updating the decimation factor.
    release(rx)
    rx.DecimationFactor = DecimationFactor(n);
    SampleRate(n,2) = MCR/DecimationFactor(n);
    % Receive data and log any overruns.
    for i = 1:frames
        [~,~,overrun] = rx();
        if overrun
            OverrunCount(n,2) = ...
                OverrunCount(n,2)+1;
        end
    end
end

Release the hardware resources.

release(rx);

Convert the overrun data to a percentage, rounded to the nearest percentage point.

pOverrunCount(:,2) = ...
    round(OverrunCount(:,2)/frames*100);

Tabulate the results.

table(SampleRate(:,2)/1e6,pOverrunCount(:,2), ...
    VariableNames=["Sample Rate (MHz)","Overruns (%)"])
ans=8×2 table
    Sample Rate (MHz)    Overruns (%)
    _________________    ____________

          6.144               0      
           12.8               0      
           19.2               0      
          30.72               0      
           38.4               0      
           51.2               0      
           76.8               0      
          153.6               0      

Compare Performance

Plot the results to compare the performance of the 1 GigE link with the 10 GigE link. A 10 Gigabit Ethernet link is required to receive data at sample rates in excess of 25 MHz.

sampleRate_MHz = SampleRate/1e6;
plot(sampleRate_MHz,OverrunCount,'-o')
grid on
xlabel("Sample Rate (MHz)")
ylabel("Overruns (%)")
legend("1 GigE","10 GigE")

Figure contains an axes object. The axes object with xlabel Sample Rate (MHz), ylabel Overruns (%) contains 2 objects of type line. These objects represent 1 GigE, 10 GigE.

See Also

Topics