在MATLAB Signal Processing Toolbox中取消findpeaks警告
问题描述:
我使用了MATLAB信号处理工具箱中的函数 findpeaks .但是每次该函数找不到任何峰值时,我都会收到警告:
I use the function findpeaks from MATLAB's Signal Processing Toolbox. But everytime the function does not find any peaks I receive the warning:
Warning: No peaks found.
> In findpeaks at 83
现在我还是要处理这些情况,因此请检查findpeaks
返回的向量是否为空.因此,我想禁止显示这些警告,因为我不希望我的命令窗口变得混乱.
Now I have to handle those cases anyway and therefore check if the vector returned by findpeaks
is empty. So I would like to suppress those warnings, because I don't want my Command Window to get cluttered up.
答
首先确定警告ID:
findpeaks([1 1 1 1 ]);
[msg id] = lastwarn;
然后关闭警告:
warning('off',id)