Callback function pointer in Matlab
8 次查看(过去 30 天)
显示 更早的评论
I am trying to call a function from Matlab NI daqmx toolbox:
function [status, callbackData] = DAQmxRegisterEveryNSamplesEvent(uint64 task, int32 everyNsamplesEventType, uint32 nSamples, uint32 options, DAQmxEveryNSamplesEventCallbackPtr callbackFunction, void* callbackData)
This function requires a callbackFunction pointer as input but I have no idea how to create that in Matlab and matlab function handle doesn't work for it. Could anyone help me with this issue?
0 个评论
回答(1 个)
Image Analyst
2019-12-23
You put an @ symbol in front of the argument when you call it. For example calling it might look like
[status, callbackData] = DAQmxRegisterEveryNSamplesEvent(task, everyNsamplesEventType,...
nSamples, options, DAQmxEveryNSamplesEventCallbackPtr, @MyCallbackFunction, callbackData)
where you've assigned values for the other arguments. Then you'd define that MyCallbackFunction() function somewhere, like
function results = MyCallbackFunction()
% code...
% The function needs to know what will be given to it when DAQmxRegisterEveryNSamplesEvent() gives stuff to it
% and what kind of data DAQmxRegisterEveryNSamplesEvent() expects to get back after MyCallbackFunction has been executed.
3 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Instrument Control Toolbox Supported Hardware 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!