フィルターのクリア

Trouble getting function to work. Not enough inputs.

3 ビュー (過去 30 日間)
Tyler Bodnarik
Tyler Bodnarik 2020 年 10 月 15 日
回答済み: Steven Lord 2020 年 10 月 15 日
I'm trying to write a function that will output the indices of all local maxima and minima of a function. I was able to write code to do so but not within a function. I have this:
function [maxima,minima] = min_max(y)
maxx = islocalmin(y);
minn = islocalmax(y);
maxima = find(maxx == 1);
minima = find(minn == 1);
end
If i just use the code inside the function it does exactly what I want it to but I'm having trouble getting the function to work properly. The error I'm getting is not enough input arguments. Any advice on how to get this function to execute?

採用された回答

Steven Lord
Steven Lord 2020 年 10 月 15 日
You need to call it with one input argument, the data you want to analyze. You cannot (directly) use the green triangle button to run this code, as by default it will run your function with zero input arguments.
plot % zero input arguments, if you run this it would error
plot(1:10) % one input argument, valid syntax for calling plot.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by