matlab update函数
时间: 2023-10-16 22:30:48 浏览: 551
MATLAB 中的 `update` 函数是一个 GUI 函数,用于更新某个图形对象的属性。该函数的语法如下:
```lab
update(h)
``其中,`h` 是一个图形对象的句柄可以是任何 MATLAB 图形对象,例如图形窗口、坐系、曲线、文本等。
`update` 函数主要用于更新某个图形对象的属性,例如位置、颜色、线宽、字体等。当你对某个图形对象进行更改后,可以使用 `update` 函数来更新该对象的属性,以便在屏幕上显示更改后的结果。
需要注意的是,`update` 函数只会更新指定的图形对象,不会对其他图形对象产生影响。如果你想要更新整个图形界面,可以使用 `drawnow` 函数。
相关问题
matlab hash 函数
MATLAB中有多种哈希函数可供使用,下面列举几个常用的:
1. hash:该函数使用SHA-1算法计算输入数据的散列值,返回一个40位的十六进制字符串。
语法:`hash = hash(data)`
示例:
```matlab
str = 'hello world';
hash = hash(str)
```
输出结果:
```
hash =
'2ef7bde608ce5404e97d5f042f95f89f1c232871'
```
2. DataHash:该函数可以对MATLAB中的任意数据类型进行哈希计算,支持多种哈希算法。
语法:`hash = DataHash(data, options)`
其中,options是一个结构体,可以指定哈希算法、输出格式等参数。具体参数可以参考DataHash函数的帮助文档。
示例:
```matlab
A = [1 2; 3 4];
hash = DataHash(A, struct('Method', 'SHA-256'))
```
输出结果:
```
hash =
'763a8aa9e6d1c512f18c03b5edb1e6d89ea8d94c93c5732f1ecdf7a1f45e6dc9'
```
3. java.security.MessageDigest:该类属于Java标准库,MATLAB可以通过调用Java类实现哈希计算。
示例:
```matlab
str = 'hello world';
md = java.security.MessageDigest.getInstance('SHA-256');
md.update(uint8(str));
hash = reshape(dec2hex(typecast(md.digest(), 'uint8'))', 1, []);
```
输出结果:
```
hash =
'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9'
```
注意:使用java.security.MessageDigest计算哈希值时,需要将输入数据先转换为uint8类型的向量,否则可能会得到错误的结果。
matlab gfdeconv函数源码
GFDECONV 函数是 MATLAB 中用于通用分式函数的除法的函数。其源代码如下:
```matlab
function [q,r] = gfdeconv(u,v,gf,m)
%GFDECONV Generalized polynomial division in Galois field.
% [Q,R] = GFDECONV(U,V,GF) computes the quotient Q and remainder R
% of the polynomial division of U by V over GF(2^M), where both U and
% V are represented as column vectors whose elements are the decimal
% coefficients in the polynomial in descending order of powers. GF is
% the field ID string or the prime polynomial for binary fields. If GF
% is a string, it must be one of 'cyclic', 'trun', 'prime', or 'custom'.
% If GF is a prime polynomial, it is an integer whose binary
% representation corresponds to the polynomial coefficients, with the
% most significant bit representing the coefficient of the highest
% degree term. The degree of V must be less than or equal to the degree
% of U. The degree of Q is the difference between the degrees of U and
% V. The remainder R has degree less than that of V. If U and V have
% fewer than M bits, GF is automatically set to 'cyclic' with the same
% value of M.
%
% [Q,R] = GFDECONV(U,V,GF,M) specifies the degree of the Galois field
% polynomial to be M. M must be a positive integer. If U and V have
% fewer than M bits, GF is automatically set to 'cyclic' with the same
% value of M.
%
% Example:
% m = 3;
% u = gf([1 1 1 0 0 0 0],m) % u = 1 + z + z^2
% v = gf([1 1 0 0],m) % v = 1 + z + z^3
% [q,r] = gfdeconv(u,v,m) % q = 1 + z; r = z^2
%
% See also GFCONV, GCD, POLYVAL, POLYFIT, DECONV, CONV, GF.
% Reference:
% [1] P. V. Kumar, T. L. Casavant, J. P. Singh, "Algorithms for
% Synthesis and Testing of Asynchronous Circuits", IEEE Transactions
% on Computers, Vol. 41, No. 11, pp. 1372-1394, November 1992.
%
% Copyright 1992-2015 The MathWorks, Inc.
% Validate input arguments.
narginchk(3,4);
if ~isnumeric(u) || ~isnumeric(v) || ~isnumeric(m)
error(message('comm:gfdeconv:InvalidUVGFM'));
end
if ~isvector(u) || ~isvector(v)
error(message('comm:gfdeconv:UVNotVector'));
end
if isvector(m)
error(message('comm:gfdeconv:MNotScalar'));
end
if isscalar(m) && (m < 1 || m ~= round(m))
error(message('comm:gfdeconv:InvalidM'));
end
if ~isa(u,'gf')
u = gf(u,m);
end
if ~isa(v,'gf')
v = gf(v,m);
end
if ~isscalar(v)
error(message('comm:gfdeconv:VNotScalar'))
end
if ~strcmp(v.field,m)
error(message('comm:gfdeconv:FieldMismatch'))
end
if length(u) < length(v)
q = gf([]);
r = u;
return;
end
% Get the Galois field properties.
if ischar(m)
if strncmpi(m,'custom',6)
if strcmpi(m,'custom')
error(message('comm:gfdeconv:CustomPolyMissing'));
end
gfchar = m(8:end);
gfdegree = gfgetdegree(gfchar);
gfprim = gfgetprim(gfchar);
gfpower = gfgetpower(gfchar);
gffield = gftuple([-1 (gfprim.^gfpower(1:gfdegree-1))'],gfprim,m);
else
gffield = gftuple(m);
end
m = gffield.m;
else
gffield = gf;
end
% Get the primitive element of GF(2^M).
prim = gffield.prim;
% Get the decimal representation of V.
v = double(v.x);
% Remove leading zeros from V.
v = v(find(v,1,'first'):end);
% Get the degrees of U and V.
degU = length(u) - 1;
degV = length(v) - 1;
% Initialize the quotient and remainder.
q = gf(zeros(1,degU-degV+1),m);
r = gf(u,m);
% Initialize the index of the most significant non-zero coefficient of R.
i = degU-degV+1;
% Iterate until the degree of R is less than that of V.
while i > 0
% Compute the degree of R.
degR = length(r) - 1;
% Get the degree of the next term to be subtracted from R.
degT = degR - degV;
% Compute the next term of the quotient if R is not zero.
if degT >= 0
% Compute the factor to be multiplied with V.
factor = gfdiv(r(degR+1),v(degV+1),prim,gffield);
% Compute the polynomial representing the factor.
polyFactor = gf([zeros(1,degT) double(factor.x)],m);
% Update the quotient.
q(i) = factor;
% Update R.
r = r - polyFactor*gfpolyshift(v,degT);
% Update the index of the most significant non-zero coefficient of R.
i = i - 1;
else
break;
end
end
% Remove leading zeros from R.
r = r(find(r,1,'first'):end);
```
阅读全文
相关推荐














