isdigital()函数

函数说明:

  主要用于检查其参数是否为十进制数字字符。

 

头文件:

  C——#include<ctype.h>
  C++——#include<cctype>

函数定义:

   int isdigit(int c) 

返回值:

  若参数c为阿拉伯数字0~9,则返回非0值,否则返回0。

实例:

C实现:

 

 1 #include <stdio.h>
 2 #include <ctype.h>
 3 
 4 int main()
 5 {
 6    int var1 = 'h';
 7    int var2 = '2';
 8     
 9    if( isdigit(var1) )
10    {
11       printf("var1 = |%c| 是一个数字\n", var1 );
12    }
13    else
14    {
15       printf("var1 = |%c| 不是一个数字\n", var1 );
16    }
17    if( isdigit(var2) )
18    {
19       printf("var2 = |%c| 是一个数字\n", var2 );
20    }
21    else
22    {
23       printf("var2 = |%c| 不是一个数字\n", var2 );
24    }
25   
26    return(0);
27 }

 

产生的结果:

var1 = |h| 不是一个数字
var2 = |2| 是一个数字

 用C++换下头文件。

参考:

https://www.runoob.com/cprogramming/c-function-isdigit.html

https://baike.baidu.com/item/isdigit/9455880?fr=aladdin

 

转载于:https://www.cnblogs.com/Anber82/p/11348738.html

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MATLAB 函数 `qammod` 的源代码如下: ```matlab function y = qammod(x,M,varargin) %QAMMOD Quadrature Amplitude Modulation modulation. % Y = QAMMOD(X,M) outputs the complex envelope Y of the modulation of % the message signal X using quadrature amplitude modulation. M is the % modulation order and must be an integer power of 2. If X is a matrix, % the function treats each column as a separate channel. % % Y = QAMMOD(X,M,S) uses constellation mapping specified by S. S must % be a complex column vector with M elements. The elements in S must be % unique and have unit magnitude. The default constellation mapping for % QAM is Gray-coded. % % Y = QAMMOD(X,M,S,SYMORDER) specifies the symbol order. The default % symbol order is 'gray'. Other options include 'bin' and 'sym'. % % % Example: % % Modulate a random signal using 16-QAM % % data = randi([0 3],100,1); % Random data stream % modSignal = qammod(data,16); % 16-QAM modulated signal % scatterplot(modSignal); % Plot constellation diagram % % See also QAMDEMOD, MODULATE, DEMODULATE, PAMMOD, PSKMOD, FSKMOD. % Copyright 2001-2019 The MathWorks, Inc. % References: % [1] Simon, M. K. and Alouini, M.-S., Digital Communication over % Fading Channels, 2nd Ed., Wiley, 2005. % [2] Proakis, J. G., Digital Communications, 3rd Ed., McGraw-Hill, 1995. narginchk(2, 4); validateattributes(x,{'double','single'},{'column','finite'},'','X'); validateattributes(M,{'numeric'},{'integer','scalar','positive'},'','M'); % Default symbol mapping is Gray-coded defaultConstellation = qammod([],M,'gray'); if nargin > 2 validateattributes(varargin{1},{'double','single'},{'column','finite','nonnan','nonempty'},'','S'); if numel(varargin) > 1 symOrder = varargin{2}; else symOrder = 'gray'; end constellation = varargin{1}; else constellation = defaultConstellation; symOrder = 'gray'; end if nargin > 3 validateattributes(symOrder,{'char'},{'nonempty'},'','SYMORDER'); symOrder = validatestring(symOrder,{'bin','gray','sym'},'','SYMORDER'); end % Validate inputs if ~isreal(constellation) error(message('comm:qammod:InvalidConstellation')); end validateattributes(constellation,{'double','single'},{'column','finite','nonnan','nonempty'},'','S'); validatestring(symOrder,{'bin','gray','sym'},'','SYMORDER'); % Calculate number of bits per symbol k = log2(M); % Validate input if mod(length(x), k) ~= 0 error(message('comm:qammod:InvalidInputLength', k)); end % Modulate using index mapping if strcmp(symOrder,'bin') || strcmp(symOrder,'sym') if strcmp(symOrder,'bin') x = bi2de(x,'left-msb'); end xMsg = de2bi(x,k,'left-msb'); xMsg = reshape(xMsg.',[],1); xIndex = bi2de(xMsg,'left-msb') + 1; % Convert to decimal index else % Gray coding xMsg = reshape(x,k,[]); xGray = sum(xMsg .* repmat(2.^(k-1:-1:0)',1,size(xMsg,2)),1); % Convert to decimal index xIndex = gray2bin(xGray,'qam',M) + 1; end % Map the message to a point in the constellation y = constellation(xIndex); end ``` 该函数实现了各种 QAM 调制方式,包括二进制、格雷码和符号映射。你可以根据自己的需求进行调用和修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值