www.gusucode.com > 关于蓝牙的很好的仿真程序(simulink加matlab)源码程序 > test_data_throughput.m

    % Measure thoughput for DM1 packet type for different SNRs
tic
clear Throughput_Results1 Throughput_Results2; % Clear previous results
    
% Define model
Modelname='bluetooth_full_duplex';

% Turn on AWGN
set_param([Modelname '/System parameters'],'Channel_type','AWGN');

%  Set devices to DM1 packet type     
set_param([Modelname '/System parameters'],'Packet_type','DM1');

Simulation_time=100/1600; % 100 slots
EsNo_tests = 9:1:14; % Range of SNR

for EsNo_test=1:length(EsNo_tests) % For each SNR level...
    
    EsNo=EsNo_tests(EsNo_test); % Set EbNo level in workspace
    
  
    %  Display SNR currently being simulated
    disp(['Testing EsNo: ' num2str(EsNo_tests(EsNo_test)) '...'] );
    
    % Run simulation
    sim(Modelname, Simulation_time);
 
    % Display results
    disp('Throughput Results:');   
    disp(['Device 1: ' num2str(Throughput1)]);   
    disp(['Device 2: ' num2str(Throughput2)]);  
    disp(' ');
    Throughput_Results1(EsNo_test)=Throughput1;
    Throughput_Results2(EsNo_test)=Throughput2;
end

% Plot total results
plot(EsNo_tests,Throughput_Results1/1000,EsNo_tests,Throughput_Results2/1000);
title('Throughput Results');
xlabel('EsNo');
ylabel('Throughput (kbps)');
axis([EsNo_tests(1)  EsNo_tests(end)  0  130]);
legend('Device 1','Device 2')
grid;
toc