Arg!
After all this time of searching and struggling to do this I finally come to search google for "Analog Discovery Matlab loadlibrary()" upon which action I found a example, I'm not sure what it gives me but it would appear that the example function tests to see if Matlab can connect to the device.
Aha, when I did the most of my work with this the thread showing this example had not been written jet... Here it is(this comes from: https://forum.digilentinc.com/topic/285-matlab-waveforms-sdk/ )
I have made some minor changes in the code to suit my file system.
function [] = DWFtest()
%DWFtest Test out the Analog Discovery Device SDK
addpath('WaveForms(2015)_SDK\inc')
addpath('WaveForms(2015)_SDK\lib\x64')
% 32 bit system
%hfile = 'C:Program FilesDigilentWaveFormsSDKincdwf.h';
%64 bit system
hfile = 'dwf.h';
display(['Set variable hfile: ' hfile]);
if ~libisloaded('dwf')
loadlibrary('dwf', hfile);
end
islibloaded = libisloaded('dwf');
fprintf('Check if dwf library is loaded: islibloaded = %dn',islibloaded)
% This is necessary to get the character strings
pBuffer = libpointer('int8Ptr',zeros(32,1));
calllib('dwf','FDwfGetVersion',pBuffer);
display(['Version: ' char(pBuffer.Value')]);
%Just opening and making sure the device is in a known state
phdwf = libpointer('int32Ptr',0);
calllib('dwf','FDwfDeviceOpen',-1,phdwf);
display(['FDwfDeviceOpen returned: ' num2str(phdwf.Value)])
% Close device and unload library
if phdwf.Value > 0
calllib('dwf','FDwfDeviceCloseAll');
end
unloadlibrary('dwf')
end