www.gusucode.com > MIMO_OFDM系统的matlab仿真程序以及GUI界面的实现源码程序 > CH9/verify_params.m
function verify_params persistent state; if isempty(state) state = struct('DataCarriers','10','TimeMaxDelay', '50', 'kfactor', '0', ... 'SimulationPackets', '1000'); end curr_obj = gcbo; obj_tag = get(curr_obj,'Tag'); % performs logical check on input parameters switch (obj_tag) case 'DataCarriers' data_carriers_str = get(curr_obj, 'String'); try data_carriers = eval(data_carriers_str); if data_carriers < 0 set(curr_obj,'String', state.DataCarriers); errordlg('Data carriers cannot be negative','Invalid input', 'modal'); else state = setfield(state, 'DataCarriers', data_carriers_str); end catch set(curr_obj,'String', state.DataCarriers); errordlg('Data carriers value not a number','Invalid input', 'modal'); end case 'FFTsixtyfour' FFTsixtyfour=get(curr_obj, 'Value'); if FFTsixtyfour==1 set(curr_obj, 'Enable', 'inactive') FFTonetwoeight = findobj('Tag', 'FFTonetwoeight'); set(FFTonetwoeight, 'Enable', 'on') set(FFTonetwoeight, 'Value', 0); FFTtwofivesix = findobj('Tag', 'FFTtwofivesix'); set(FFTtwofivesix, 'Enable', 'on') set(FFTtwofivesix, 'Value', 0); FFTfiveonetwo = findobj('Tag', 'FFTfiveonetwo'); set(FFTfiveonetwo, 'Enable', 'on') set(FFTfiveonetwo, 'Value', 0); end case 'FFTonetwoeight' FFTonetwoeight=get(curr_obj, 'Value'); if FFTonetwoeight==1 set(curr_obj, 'Enable', 'inactive') FFTsixtyfour = findobj('Tag', 'FFTsixtyfour'); set(FFTsixtyfour, 'Enable', 'on') set(FFTsixtyfour, 'Value', 0); FFTtwofivesix = findobj('Tag', 'FFTtwofivesix'); set(FFTtwofivesix, 'Enable', 'on') set(FFTtwofivesix, 'Value', 0); FFTfiveonetwo = findobj('Tag', 'FFTfiveonetwo'); set(FFTfiveonetwo, 'Enable', 'on') set(FFTfiveonetwo, 'Value', 0); end case 'FFTtwofivesix' FFTtwofivesix=get(curr_obj, 'Value'); if FFTtwofivesix==1 set(curr_obj, 'Enable', 'inactive') FFTonetwoeight = findobj('Tag', 'FFTonetwoeight'); set(FFTonetwoeight, 'Enable', 'on') set(FFTonetwoeight, 'Value', 0); FFTsixtyfour = findobj('Tag', 'FFTsixtyfour'); set(FFTsixtyfour, 'Enable', 'on') set(FFTsixtyfour, 'Value', 0); FFTfiveonetwo = findobj('Tag', 'FFTfiveonetwo'); set(FFTfiveonetwo, 'Enable', 'on') set(FFTfiveonetwo, 'Value', 0); end case 'FFTfiveonetwo' FFTfiveonetwo=get(curr_obj, 'Value'); if FFTfiveonetwo==1 set(curr_obj, 'Enable', 'inactive') FFTonetwoeight = findobj('Tag', 'FFTonetwoeight'); set(FFTonetwoeight, 'Enable', 'on') set(FFTonetwoeight, 'Value', 0); FFTtwofivesix = findobj('Tag', 'FFTtwofivesix'); set(FFTtwofivesix, 'Enable', 'on') set(FFTtwofivesix, 'Value', 0); FFTsixtyfour = findobj('Tag', 'FFTsixtyfour'); set(FFTsixtyfour, 'Enable', 'on') set(FFTsixtyfour, 'Value', 0); end case 'AWGN' awgn_val = get(curr_obj, 'Value'); if awgn_val == 1 set(curr_obj, 'Enable', 'inactive') exp_decay_chan = findobj('Tag', 'MaxDelaySpread'); set(exp_decay_chan, 'Enable', 'on') set(exp_decay_chan, 'Value', 0); rician = findobj('Tag', 'Rician'); set(rician, 'Enable', 'on') set(rician, 'Value', 0); vblast=findobj('Tag','VBLAST'); set(vblast,'Enable','on'); set(vblast,'Value',0); end case 'MaxDelaySpread' exp_decay_val = get(curr_obj, 'Value'); if exp_decay_val == 1 set(curr_obj, 'Enable', 'inactive'); awgn_chan = findobj('Tag', 'AWGN'); set(awgn_chan, 'Enable', 'on') set(awgn_chan, 'Value', 0); rician = findobj('Tag', 'Rician'); set(rician, 'Enable', 'on') set(rician, 'Value', 0); end case 'kfactor' kfactor_str = get(curr_obj,'String'); try kfactor = eval(kfactor_str); if kfactor < 0 set(curr_obj, 'String', state.kfactor); errordlg('K factor cannot be negative','Invalid input', 'modal'); else state = setfield(state, 'kfactor', kfactor_str); end catch set(curr_obj,'String', state.kfactor); errordlg('K factor value not a number','Invalid input', 'modal'); end case 'TimeMaxDelay' exp_decay_trms_str = get(curr_obj,'String'); try exp_decay_trms = eval(exp_decay_trms_str); if exp_decay_trms < 0 set(curr_obj, 'String', state.TimeMaxDelay); errordlg('Exponential decay T rms cannot be negative','Invalid input', 'modal'); else state = setfield(state, 'TimeMaxDelay', exp_decay_trms_str); end catch set(curr_obj,'String', state.TimeMaxDelay); errordlg('Exponential decay T rms value not a number','Invalid input', 'modal'); end case 'Rician' rician = get(curr_obj, 'Value'); if rician == 1 set(curr_obj, 'Enable', 'inactive'); awgn_chan = findobj('Tag', 'AWGN'); set(awgn_chan, 'Enable', 'on') set(awgn_chan, 'Value', 0); exp_decay_chan = findobj('Tag', 'MaxDelaySpread'); set(exp_decay_chan, 'Enable', 'on') set(exp_decay_chan, 'Value', 0); end case 'ChannelEstimation_LSE' channel_est_lse = get(curr_obj,'Value'); vblast = get(findobj('Tag', 'VBLAST'),'Value'); if vblast==1 channel_est_lse = findobj('Tag', 'ChannelEstimation_LSE'); channel_est_fft = findobj('Tag', 'ChannelEstimation_FFT'); set(channel_est_lse,'Value',0); set(channel_est_fft,'Value',0); h=msgbox('You have selected VBlast option.Channel estimation is disabled. ','VBlast Algorithm','warn','modal'); set(h,'Position',[235 220 300 100.25]) end case 'ChannelEstimation_FFT' channel_est_fft = get(curr_obj,'Value'); vblast = get(findobj('Tag', 'VBLAST'),'Value'); if channel_est_fft==1 channel_est_lse = findobj('Tag', 'ChannelEstimation_LSE'); set(channel_est_lse,'Value',1); end if vblast==1 channel_est_lse = findobj('Tag', 'ChannelEstimation_LSE'); channel_est_fft = findobj('Tag', 'ChannelEstimation_FFT'); set(channel_est_lse,'Value',0); set(channel_est_fft,'Value',0); h=msgbox('You have selected VBlast option.Channel estimation is disabled. ','VBlast Algorithm','warn','modal'); set(h,'Position',[235 220 300 100.25]) end case 'SimulationPackets' pkts_to_simulate_str = get(curr_obj, 'String'); try pkts_to_simulate = eval(pkts_to_simulate_str); if pkts_to_simulate < 0 set(curr_obj,'String', state.SimulationPackets); errordlg('Packets to simulate cannot be negative','Invalid input', 'modal'); else state = setfield(state, 'SimulationPackets', pkts_to_simulate_str); end catch set(curr_obj,'String', state.SimulationPackets); errordlg('Packets to simulate value not a number','Invalid input', 'modal'); end case 'MIMO_Tx. Antennas' txa = get(curr_obj,'String'); try txa = eval(txa); state = setfield(state, 'M', txa); catch set(curr_obj,'String', state.M); errordlg('Tx. Antenna value not a number','Invalid input', 'modal'); end case 'MIMO_Rx. Antennas' rxa = get(curr_obj,'String'); try rxa = eval(rxa); state = setfield(state, 'N', rxa); catch set(curr_obj,'String', state.N); errordlg('Rx. Antenna value not a number','Invalid input', 'modal'); end case 'VBLAST' vblast = get(findobj('Tag', 'VBLAST'),'Value'); if vblast == 1 txdiv2 = findobj('Tag', 'MIMO_TwoTxAntennas'); txdiv4 = findobj('Tag', 'MIMO_FourTxAntennas'); rxdiv2 = findobj('Tag','MIMO_TwoRxAntennas'); rxdiv4 = findobj('Tag','MIMO_FourRxAntennas'); interleave_bits=findobj('Tag', 'InterleavingBits'); set(txdiv2, 'Value', 0); set(txdiv4, 'Value', 0); set(rxdiv2, 'Value', 0); set(rxdiv4, 'Value', 0); set(interleave_bits,'Value',0); channel_est_lse = findobj('Tag', 'ChannelEstimation_LSE'); channel_est_fft = findobj('Tag', 'ChannelEstimation_FFT'); set(channel_est_lse,'Value',0); set(channel_est_fft,'Value',0); awgn_chan = findobj('Tag', 'AWGN'); set(awgn_chan,'Enable','on'); set(awgn_chan, 'Value', 0); exp_decay_chan = findobj('Tag', 'MaxDelaySpread'); set(exp_decay_chan, 'Enable', 'on') set(exp_decay_chan, 'Value', 1); rician = findobj('Tag', 'Rician'); set(rician, 'Enable', 'on') set(rician, 'Value', 0); msgbox('This program only deals with 1 x 2, 2 x 2, 2 x 3 and 2 x 4 systems.There is no interleaving,no channel estimation and no AWGN channel.The default channel is a Rayleigh channel.','VBlast Algorithm','warn','modal'); end case 'MIMO_TwoTxAntennas' use_tx_div2 = get(findobj('Tag', 'MIMO_TwoTxAntennas'),'Value'); if use_tx_div2==1 vblast=findobj('Tag','VBLAST'); set(vblast,'Value',0); use_tx_div4=findobj('Tag', 'MIMO_FourTxAntennas'); set(use_tx_div4,'Value',0); end case 'MIMO_FourTxAntennas' use_tx_div4 = get(findobj('Tag', 'MIMO_FourTxAntennas'),'Value'); if use_tx_div4==1 vblast=findobj('Tag','VBLAST'); set(vblast,'Value',0); use_tx_div2=findobj('Tag', 'MIMO_TwoTxAntennas'); set(use_tx_div2,'Value',0); end case 'MIMO_TwoRxAntennas' use_rx_div2 = get(findobj('Tag', 'MIMO_TwoRxAntennas'),'Value'); if use_rx_div2==1 vblast=findobj('Tag','VBLAST'); set(vblast,'Value',0); use_rx_div4=findobj('Tag', 'MIMO_FourRxAntennas'); set(use_rx_div4,'Value',0); end case 'MIMO_FourRxAntennas' use_rx_div4 = get(findobj('Tag', 'MIMO_FourRxAntennas'),'Value'); if use_rx_div4==1 vblast=findobj('Tag','VBLAST'); set(vblast,'Value',0); use_rx_div2=findobj('Tag', 'MIMO_TwoRxAntennas'); set(use_rx_div2,'Value',0); end case 'InterleavingBits' interleave_bits = get(findobj('Tag', 'InterleavingBits'),'Value'); if interleave_bits==1 vblast=findobj('Tag','VBLAST'); set(vblast,'Value',0); end case 'ZeroPad' zeropad=get(findobj('Tag', 'ZeroPad'),'Value'); if zeropad==1 h1=findobj('Tag','DataCarriers'); set(h1,'Visible','On'); h1=findobj('Tag','StaticText'); set(h1,'Visible','On'); % Interleaving InterleavingBits = findobj('Tag', 'InterleavingBits'); set(InterleavingBits,'Visible','Off'); else h1=findobj('Tag','DataCarriers'); set(h1,'Visible','Off'); h1=findobj('Tag','StaticText'); set(h1,'Visible','Off'); % Interleaving InterleavingBits = findobj('Tag', 'InterleavingBits'); set(InterleavingBits,'Visible','On'); end case 'FileName' filename_str = str2double(get(curr_obj,'String')); try filename = eval(filename_str); state = setfield(state, 'FILE_FileName', filename_str); end otherwise end