Use of arrayfun but with passing a fixed variable to function handle?

3 ビュー (過去 30 日間)
Eva-Maria Weiss
Eva-Maria Weiss 2020 年 5 月 25 日
回答済み: James Tursa 2020 年 5 月 25 日
Hi!
I hope someone can help me with this.
The first column of my matrix contains start indices and the second stop indices that should be used to read out a segment from another vector.
From that segment some calculations are done returning a scalar, that should be stored in a third column.
This code shows the idea. WIth spikeTimes is the external vector providing the segments.
For sure it's not working, since spikeTimes is a kind of fixed variable whith another size.
matrix(:,1) = start_temp;
matrix(:,2) = stop_temp;
f = @computeS;
matrix(:,3) = arrayfun(f,start_temp,stop_temp, spikeTimes);
function thresh = computeS(a,b,spikeTimes)
thresh = max(diff(spikeTimes(a:b)));
end
And it was just an idea,I'm happy about any thoughts about a proper solution. Maybe the best is simply running a loop?
Thank you in advance, I appreciate any hints!
Eva
  1 件のコメント
Eva-Maria Weiss
Eva-Maria Weiss 2020 年 5 月 25 日
Meanwhile I found something in the provided answers here using argument binding:
Thanks to Guillaume for that solution!!!!!
I'm still open for other ideas and thoughts!

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

採用された回答

James Tursa
James Tursa 2020 年 5 月 25 日
matrix(:,3) = arrayfun(@(a,b)max(diff(spikeTimes(a:b))),start_temp,stop_temp);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by