Returning a value from a function after click in figure
6 ビュー (過去 30 日間)
古いコメントを表示
Markus Toivonen
2018 年 4 月 18 日
コメント済み: Walter Roberson
2018 年 4 月 18 日
I would like to return a value from a function, based on the type of click that was used.
I have the following codes:
figure
i = 0;
plot(rand(5))
val = set(gca,'buttondownfcn',@mybttnfcn)
and
function value = mybttnfcn(h,~)
hf = get(h,'parent');
b = get(hf,'selectiontype');
if strcmpi(b,'normal')
value = 1;
disp(value)
elseif strcmpi(b,'alt')
value = -1;
disp(value)
else
value = 0;
disp(value)
end
I would want to capture the 'value' from the function, into a variable where the call happens. Thanks!
0 件のコメント
採用された回答
Walter Roberson
2018 年 4 月 18 日
Callbacks cannot return values (except for position constraints functions). You need to get the value out a different way.
https://www.mathworks.com/help/matlab/creating_guis/share-data-among-callbacks.html
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!