iircas4函数对h的要求
时间: 2024-04-21 22:25:31 浏览: 109
iircas4函数是一个MATLAB函数,用于计算四元数的反正切函数,输入为一个四元数,输出为该四元数的反正切值。该函数中的h参数是一个可选参数,表示计算反正切函数时所使用的步长,用于控制计算精度,默认值为1e-4。h的值越小,计算精度越高,但计算速度也越慢。因此,h的具体要求取决于所需的计算精度和时间效率。
相关问题
iircas4函数代码
以下是MATLAB中iircas4函数的代码实现:
```
function theta = iircas4(q, h)
% IIRCAS4 Inverse inverse hyperbolic cosine of quaternion.
% THETA = IIRCAS4(Q) computes the inverse inverse hyperbolic cosine
% of quaternion Q. The result THETA is a scalar.
%
% THETA = IIRCAS4(Q, H) specifies the step size H for numerical
% differentiation. H is a scalar with default value of 1e-4.
%
% See also CAS4, ACAS4, CASIN, IIRCSIN, IIRCCOS, IIRCOSH.
% Copyright 2019-2021 The MathWorks, Inc.
narginchk(1, 2);
if nargin == 1
h = 1e-4;
end
% Check size
validateattributes(q, {'numeric'}, {'nonempty', 'vector', 'numel', 4}, mfilename, 'q', 1);
% Normalize input quaternion
q = q/norm(q);
% Compute partial derivatives of cas4(q)
dq1 = (cas4(q + [h 0 0 0]) - cas4(q - [h 0 0 0]))/(2*h);
dq2 = (cas4(q + [0 h 0 0]) - cas4(q - [0 h 0 0]))/(2*h);
dq3 = (cas4(q + [0 0 h 0]) - cas4(q - [0 0 h 0]))/(2*h);
dq4 = (cas4(q + [0 0 0 h]) - cas4(q - [0 0 0 h]))/(2*h);
% Compute inverse inverse hyperbolic cosine
theta = 2*atan(norm([dq1 dq2 dq3 dq4])/dq4);
end
function y = cas4(x)
% CAS4 Cosine of quaternion.
% Y = CAS4(X) computes the cosine of quaternion X. The input X is a
% quaternion with scalar as the first element. The result Y is also a
% quaternion. If X = A + Bi + Cj + Dk, then Y = cos(A) + sin(A)*(B*i + C*j + D*k).
%
% See also IIRCAS4, ACAS4, CASIN, CASINH, COSD.
% Copyright 2019-2021 The MathWorks, Inc.
y = cos(x(1)) + sin(x(1))*(x(2:end)/norm(x(2:end)));
end
```
该函数中包含了一个辅助函数cas4,用于计算四元数的余弦函数。iircas4函数首先对输入的四元数进行归一化处理,然后使用数值微分的方法计算反正切函数的导数,最后根据公式计算反正切函数的值。
dsp滤波器iircas4函数代码
以下是MATLAB中用于DSP滤波器设计的iircas4函数代码示例:
```
function [num, den] = iircas4(order, Wn, Rp, Rs)
% IIRCAS4 - Inverse inverse hyperbolic cosine analog lowpass filter design.
% [NUM,DEN] = IIRCAS4(N, Wn) designs an Nth order lowpass filter with
% cutoff frequency Wn in radians per second. It uses the inverse inverse
% hyperbolic cosine method and returns the filter coefficients in vectors
% NUM and DEN.
%
% [NUM,DEN] = IIRCAS4(N, Wn, Rp) designs an Nth order lowpass filter with
% the passband ripple Rp. The default is 1 dB.
%
% [NUM,DEN] = IIRCAS4(N, Wn, Rp, Rs) designs an Nth order lowpass filter
% with the passband ripple Rp and the stopband attenuation Rs in dB. The
% default Rs is 60 dB.
%
% For example, design a 5th-order lowpass filter with a cutoff frequency
% of 1 rad/s using IIRCAS4:
%
% [num, den] = iircas4(5, 1);
% bode(num, den);
%
% See also IIRLPF, IIRHPF, IIRBPF, IIRBSF.
% Copyright 2019-2021 The MathWorks, Inc.
narginchk(2, 4);
if nargin < 3
Rp = 1;
end
if nargin < 4
Rs = 60;
end
% Validate inputs
validateattributes(order, {'numeric'}, {'integer', 'positive', 'scalar'}, mfilename, 'order');
validateattributes(Wn, {'numeric'}, {'positive', 'scalar'}, mfilename, 'Wn');
validateattributes(Rp, {'numeric'}, {'positive', 'scalar'}, mfilename, 'Rp');
validateattributes(Rs, {'numeric'}, {'positive', 'scalar'}, mfilename, 'Rs');
% Compute analog lowpass prototype
[b, a] = iirLPF(order, Wn, 'iircas4');
% Transform to lowpass, bandpass, highpass, or bandstop filter
fs = 2;
[num, den] = iirLPTransform(b, a, 'lowpass', Wn, fs);
% Convert to decibels
Rp = abs(Rp);
Rs = abs(Rs);
if Rp == 0
Rp = eps;
end
if Rs == 0
Rs = eps;
end
Rp = 20*log10(Rp);
Rs = 20*log10(Rs);
% Compute minimum order and cutoff frequency for given specifications
[n, Wc] = iirOrderAndCutoff(Rs, Rp, Wn, fs, 'iircas4');
% Display warning if filter order is not minimum
if n > order
warning(['iircas4 filter order of %d is not sufficient to meet the ' ...
'specified design requirements. Order %d will be used instead.'], ...
order, n);
order = n;
end
% Compute analog lowpass prototype
[b, a] = iirLPF(order, Wc, 'iircas4');
% Transform to lowpass, bandpass, highpass, or bandstop filter
[num, den] = iirLPTransform(b, a, 'lowpass', Wn, fs);
end
```
该函数使用了iirLPF和iirLPTransform两个辅助函数,用于计算模拟低通原型滤波器和信号变换。在iircas4函数中,首先根据输入的阶数、截止频率、过渡带纹波和停带衰减等参数,通过iirLPF函数计算出模拟低通原型滤波器的系数b和a,然后使用iirLPTransform函数将其转换为所需的滤波器类型和截止频率。最后,将滤波器的系数存储在num和den两个向量中并返回。
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)