matlab - 为什么 MATLAB 中两个数组的卷积会产生“NaN”值?
问题描述
我正在尝试计算曲线与缩放小波的卷积。使用 MATLAB 卷积函数https://www.mathworks.com/help/matlab/ref/conv.html,结果开头有大量的 'NaN' 值,我想了解这些在哪里来自(哪里。
我对卷积的直觉是不应该这样,因为我在卷积的每个点都定义了上限。我想象这个卷积的方式是小波被翻转,然后在曲线上从左到右移动。当它移动时,小波与曲线交点下方的区域存储在输出中。如果是这种情况,则结果输出应该存在并且在卷积的所有点上都是正的,除非没有重叠并且结果为 0。
% The curve is a set of responses to presented stimuli,
% and the following is an example:
curve = [0.0500, 0.1000, 0.1500, 0.2000, 0.3000, 0.5000, 0.8000;
11.6465, 14.8354, 5.0695, 0.4856, 0.5858, 0.2863, 0.3864];
% The scaled Mexican hat wavelet is as follows:
acuteness = 1000;
[mexh_y, mexh_x] = mexihat(-5,5,acuteness);
max_response = max(curve(2,:));
wav_x = mexh_x/100;
wav_y = mexh_y * (max_response+1);
% Here wav_x are the wavelet’s x-values and wav_y are the wavelet’s y-values.
% I interpolate the original curve to have more values as follows:
max_presentation = max(curve(1,:));
step = max_presentation/acuteness;
sf_vals_for_interpolation = [step:step:max_presentation];
interp_curve = interp1(curve(1,:),curve(2,:),sf_vals_for_interpolation);
% Now I’d like to perform a convolution:
conv_res = conv(interp_curve, wav_y);
如摘要中所述,生成的卷积包含许多我想理解的“NaN”值。
解决方案
推荐阅读
- c# - c#如何为序列化指定自定义接口
- html - “C++”而不是“C++”会阻碍搜索引擎索引吗?
- scala - 如何避免while循环并在scala中返回
- haskell - Haskell - 涉及 2 个字符串列表的 foldr
- python - 当我声明大小限制时,为什么我的 tkinter 顶层很大?
- reactjs - 无法使用钩子映射获取的数据
- r - 在 R 中转换数据框数据
- angularjs - 鼠标悬停时将相同的线条颜色填充到多折线图上的圆圈,鼠标移出时从圆圈中删除颜色
- visual-studio-code - Error1 上传失败 vscode: "ser_open(): can't open device ".\COM11""
- python-3.x - AttributeError:“NoneType”对象没有属性“坐标”