⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prcsofcmdline.m

📁 从 Win32 控制台程序调用MATLAB C Math Library,从VC++中调用m函数,有几十个例子
💻 M
字号:
function [cmdLineErr, commSysNew]=prcsofcmdline(commSysDefault,varargin,paramLen)
% PRCSOFCMDLINE - processing command line parameters

commSysNew=commSysDefault;
cmdLineErr=0;
cmdLine=lower(varargin);
k=1;

while k<=paramLen % beginning of while
    if findstr('.mat',cmdLine{k})~=[] % beginning of if
       FID=fopen(cmdLine{k},'w');
       if FID~=-1
           commSysNew.dataFileName=cmdLine{k};
           fclose(FID);
           k=k+1;
       else
       	   disp('Argument filename error! The filename should be *.mat, such as data.mat, file1.mat and so on.');
           cmdLineErr=1;
       end
    else % else of if 
        switch cmdLine{k}
        case '/s'
             if k+1<=paramLen
                temp=eval(cmdLine{k+1},'-1'); % -1 can not be a  sampling frequency
                if temp~=-1&isnumeric(temp)
                    commSysNew.Fs=temp*1000000;
                    k=k+2;
                else
                    disp('Argument Fs! The Fs should be a positive scalar or array.');
                    cmdLineErr=1;
                end
            else
                disp('Argument Fs! The Fs should be a positive scalar or array.');
                cmdLineErr=1;
            end
        case '/r'
             if k+1<=paramLen
                temp=eval(cmdLine{k+1},'-1'); % -1 can not be a Eb/N0
                if temp~=-1&isnumeric(temp)
                    commSysNew.Eb_N0=temp;
                    k=k+2;
                else
                    disp('Argument Eb_N0 error! The Eb_N0 should be a positive scalar or array.');
                    cmdLineErr=1;
                end
            else
                disp('Argument Eb_N0 error! The Eb_N0 should be a positive scalar or array.');
                cmdLineErr=1;
            end
        case '/c'
             if k+1<=paramLen
                temp=eval(cmdLine{k+1},'-1'); % -1 can not be a channel type
                if temp~=-1&isnumeric(temp)
                    commSysNew.channelType=temp;
                    k=k+2;
                else
                    disp('Argument channel_model error! The channel_model is presented by a integral scalar or array between 0-7.');
                    cmdLineErr=1;
                end
            else
                disp('Argument channel_model error! The channel_model is presented by a integral scalar or array between 0-7.');
                cmdLineErr=1;
            end
        case '/m'
            if k+1<=paramLen
                temp=eval(cmdLine{k+1},'-1'); % -1 can not be a mapping mode
                if temp~=-1&isnumeric(temp)
                    commSysNew.wordSize=temp;
                    k=k+2;
                else
                    disp('Argument mapping_mode error! The mapping_mode is presented by a integral scalar or array including 1,2,4 or 6.');
                    cmdLineErr=1;
                end
            else
                disp('Argument mapping_mode error! The mapping_mode is presented by a integral scalar or array including 1,2,4 or 6.');
                cmdLineErr=1;
            end
        case '/f'
             if k+1<=paramLen
                temp=eval(cmdLine{k+1},'-1'); % -1 can not be a IFFT size
                if temp~=-1&isnumeric(temp)
                    commSysNew.ifftSize=temp;
                    k=k+2;
                else
                    disp('Argument points_in_a_IFFT IFFT size error! The points_in_a_IFFT should be a positive integral scalar or array.');
                    cmdLineErr=1;
                end
            else
                disp('Argument points_in_a_IFFT IFFT size error! The points_in_a_IFFT should be a positive integral scalar or array.');
                cmdLineErr=1;
            end
        case '/t'
             if k+1<=paramLen
                temp=eval(cmdLine{k+1},'-1'); % -1 can not be a total transmitted bits
                if temp~=-1&isnumeric(temp)
                    commSysNew.totalBits=temp;
                    k=k+2;
                    if length(commSysNew.totalBits)>1|commSysNew.totalBits < 1
                        disp('Argument total_transmitted_data_bits error! The total_transmitted_data_bits should be a positive integral scalar.');
                        cmdLineErr=1;
                    end
                else
                    disp('Argument total_transmitted_data_bits error! The total_transmitted_data_bits should be a positive integral scalar.');
                    cmdLineErr=1;
                end
            else
                disp('Argument total_transmitted_data_bits error! The total_transmitted_data_bits should be a positive integral scalar.');
                cmdLineErr=1;
            end
        case '/p'
             if k+1<=paramLen
                temp=eval(cmdLine{k+1},'-1'); % -1 can not be a cyclic prefix length
                if temp~=-1&isnumeric(temp)
                    commSysNew.cpLenRatio=temp;
                    if max(commSysNew.cpLenRatio)>1|min(commSysNew.cpLenRatio)<0
                        disp('Argument cyclic_prefix_length error! The cyclic_prefix_length should be a numeric scalar or array between 0.0-1.0.');
                        cmdLineErr=1;
                    end  
                    k=k+2;
                else
                    disp('Argument cyclic_prefix_length error! The cyclic_prefix_length should be a numeric scalar or array between 0.0-1.0.');
                    cmdLineErr=1;
                end
            else
                disp('Argument cyclic_prefix_length error! The cyclic_prefix_length should be a numeric scalar or array between 0.0-1.0.');
                cmdLineErr=1;
            end
        otherwise
            disp('Command Line error!');
            cmdLineErr=1;
        end
    end % end of if
    if cmdLineErr
        disphelp;
        return;
    end         
end % end of while

% check if the input parameters is correct
% .....
%

temp=commSysNew.ifftSize*commSysNew.wordSize;
LstComMult=1;
for i=1:length(temp)
    LstComMult=lcm(LstComMult,temp(i));
end
    
commSysNew.totalBits=max(ceil(commSysNew.totalBits/LstComMult),1)*LstComMult;
commSysNew.cpLen=ceil(max(commSysNew.ifftSize)*commSysNew.cpLenRatio);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -