フィルターのクリア

'double' input argument not found using a function

5 ビュー (過去 30 日間)
Joachim
Joachim 2013 年 5 月 22 日
回答済み: Steven Lord 2017 年 10 月 30 日
Hello,
I have got a int16 array (called allAudio) and would like to run the function 'findpeaks' on it. When I write pks = findpeaks(allAudio(1,:)), the error message says: "Error using findpeaks (line 59) Input arguments must be 'double'."
I don't understand it... Any thoughts?

採用された回答

Iain
Iain 2013 年 5 月 22 日
findpeaks only operates on numbers that are 64 bit floating point numbers (they're called doubles).
Convert your 16bit integers to double with the function "double".
double_allAudio = double(allAudio);
  2 件のコメント
Joachim
Joachim 2013 年 5 月 22 日
Great!
here's the last bit of the code I wrote to make it work (Had to transpose the matrix)
allAudio_transp=allAudio.';
double_allAudio = double(allAudio);
[pks,locs] = findpeaks(double_allAudio(1,:))
kemo
kemo 2017 年 10 月 30 日
Hello all, But what if we need to specify a certain datatype for the arguments and give the inputs accordingly??

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2017 年 10 月 30 日
In release R2017b we introduced functions islocalmax and islocalmin that support a data input A of double, single, or one of the integer types.
rng default
x = randi(10, 1, 20, 'int8');
ILM = islocalmax(x);
y = [x; ILM]
If you run those four commands, you'll see y is an int8 array and that most of the instances of 10 in x are local maxima, as is one of the instances of 9. To see that graphically:
% NaN values don't get plotted so preallocate then fill the local maxima
z = NaN(size(x));
z(ILM) = x(ILM);
ind = 1:numel(x);
plot(ind, x, '-', ind, z, 'ro');
The red circles correspond to the local maxima. The two plateaus each have one of their two points of equal height marked; see the documentation for islocalmax for more information about how you can customize how that behavior is handled.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by