MATLAB算积分的论文,matlab数值积分的实现:时域积分和频域积分 -转载

function dataout =  iomega(datain, dt, datain_type, dataout_type)

%%%%%%%%%%%%%%%%

%

%   IOMEGA is a MATLAB script for converting displacement, velocity, or

%   acceleration time-series to either displacement, velocity, or

%   acceleration times-series. The script takes an array of waveform data

%   (datain), transforms into the frequency-domain in order to more easily

%   convert into desired output form, and then converts back into the time

%   domain resulting in output (dataout) that is converted into the desired

%   form.

%

%   Variables:

%   ———-

%

%   datain       =   input waveform data of type datain_type

%

%   dataout      =   output waveform data of type dataout_type

%

%   dt           =   time increment (units of seconds per sample)

%

%                    1 – Displacement

%   datain_type  =   2 – Velocity

%                    3 – Acceleration

%

%                    1 – Displacement

%   dataout_type =   2 – Velocity

%                    3 – Acceleration

%

%

%%%%%%%%%%%%%%%%

%   Make sure that datain_type and dataout_type are either 1, 2 or 3

if (datain_type < 1 || datain_type > 3)

error('Value for datain_type must be a 1, 2 or 3');

elseif (dataout_type < 1 || dataout_type > 3)

error('Value for dataout_type must be a 1, 2 or 3');

end

%   Determine Number of points (next power of 2), frequency increment

%   and Nyquist frequency

N = 2^nextpow2(max(size(datain)));

df = 1/(N*dt);

Nyq = 1/(2*dt);

%   Save frequency array

iomega_array = 1i*2*pi*(-Nyq : df : Nyq-df);

iomega_exp = dataout_type – datain_type;

%   Pad datain array with zeros (if needed)

size1 = size(datain,1);

size2 = size(datain,2);

if (N-size1 ~= 0 && N-size2 ~= 0)

if size1 > size2

datain = vertcat(datain,zeros(N-size1,1));

else

datain = horzcat(datain,zeros(1,N-size2));

end

end

%   Transform datain into frequency domain via FFT and shift output (A)

%   so that zero-frequency amplitude is in the middle of the array

%   (instead of the beginning)

A = fft(datain);

A = fftshift(A);

%   Convert datain of type datain_type to type dataout_type

for j = 1 : N

if iomega_array(j) ~= 0

A(j) = A(j) * (iomega_array(j) ^ iomega_exp);

else

A(j) = complex(0.0,0.0);

end

end

%   Shift new frequency-amplitude array back to MATLAB format and

%   transform back into the time domain via the inverse FFT.

A = ifftshift(A);

datain = ifft(A);

%   Remove zeros that were added to datain in order to pad to next

%   biggerst power of 2 and return dataout.

if size1 > size2

dataout = real(datain(1:size1,size2));

else

dataout = real(datain(size1,1:size2));

end

return

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值