Making connection to hardware using MATLAB - matlab

I'm trying to make a connection to hardware (a controller of a moving stage) from Physik Insrumente using MATLAB. However, I have tried using the code that the company provided but did not work, so I have simplified but still doesn't work.
Here is my code:
addpath ( 'C:\Users\Public\PI\PI_MATLAB_Driver_GCS2' );
Controller = PI_GCS_Controller();
controllerSerialNumber = '118011005';
C867 = Controller.ConnectUSB(controllerSerialNumber);
display(C867.qIDN())
I am getting this error message:
PI_MATLAB_Driver_GCS2 loaded successfully.
Error using PI_GCS_Controller/ConnectUSB (line 17)
There is no interface or DLL handle with the given ID
Error in PI_GCS_Controller/ConnectUSB (line 17)
error(szDesc);
Error in PI_GCS_Controller/subsref (line 46)
varargout{1} = feval(fun,c,par{1});
Error in Untitled (line 5)
C867 = Controller.ConnectUSB(controllerSerialNumber);
ConnectUSB is:
function [c] = ConnectUSB(c,szIdentifier)
FunctionName = 'PI_ConnectUSB';
if(any(strcmp(FunctionName,c.dllfunctions)))
if(nargin<2), szIdentifier = blanks(5000); end,
try
[c.ID, szIdentifier] = calllib(c.libalias,FunctionName,szIdentifier);
if(c.ID<0)
iError = GetError(c);
szDesc = TranslateError(c,iError);
error(szDesc);
end
catch
rethrow(lasterror);
end
else
error('%s not found',FunctionName);
end
How can I connect to this controller?

Related

I'm trying to train the code of Target-Aware Deep Tracking in matlab

I'm for now compiling in CPU version.I am working on matlab 2020a.I've tried to remove the vl_nnconv.m from matconvnet but i still get the following error.
Also the matconvnet i'm using is version matconvnet-1.0-beta25 I'm stuck here since 2 days ,could somebody lease help me out with this issue?
https://github.com/XinLi-zn/TADT
The above is the github code i'm trying to work on.
Foloowing are the errors i'm getting:
Error using vl_nnconv
The option name is not a string (argument number 5)
Error in dagnn.Conv/forward (line 11)
outputs{1} = vl_nnconv(...
Error in dagnn.Layer/forwardAdvanced (line 85)
outputs = obj.forward(inputs, {net.params(par).value}) ;
Error in dagnn.DagNN/eval (line 91)
obj.layers(l).block.forwardAdvanced(obj.layers(l)) ;
Error in get_subwindow_feature (line 37)
net_feat.eval({'input',gpuArray(patch_sw)});
Error in tadt_tracking (line 63)
feat_groups = get_subwindow_feature(net_feat, img, sw_location, input_sz, feat_layer);
Error in Demo_TADT (line 23)
[result, fps]=tadt_tracking(seq_info.img_list, seq_info.gt(1,:), vgg16_model_path, display);
the following are the functions that is causing the error and the argument is obj.pad
function outputs = forward(obj, inputs, params)
if ~obj.hasBias, params{2} = [] ; end
outputs{1} = vl_nnconv(...
inputs{1}, params{1}, params{2}, ...
'pad', obj.pad, ...
'stride', obj.stride, ...
obj.opts{:}) ;
end

How do I use PRtools' forward feature selection in MatLab?

I am trying to apply a forward feature selection on a PRdataset. Following the syntax presented online though produces a bunch of errors that I don't quite understand and haven't been able to solve. Any ideas on what is causing them or how to fix?
Code used and resulting errors shown below:
A=prdataset(data,classes);
[w,r]=featself(A,'NN');
Error using indnn (line 50)
Trainset and testset should by identical for LOO processing
Error in fnnc (line 33)
L = indnn(a,trainset,loo);
Error in prmap (line 231)
[d,varargout{:}] = feval(mapp,a,b);
Error in * (line 14)
d = prmap(a,b);
Error in testk (line 55)
d = a*w;
Error in feateval (line 128)
J = 1 - testk(a,1);
Error in featsellr>plusl (line 182)
critval = feateval(a(:,[state.I Jsub]),crit);
Error in featsellr (line 127)
state = plusl(a,crit,t,state,fid);
Error in featself (line 56)
[w,r] = featsellr(a,crit,ksel,1,0,t);

Matlab GUI callback error

i have a really strange error... i get the following:
SWITCH expression must be a scalar or string constant.
Error in RL_Bsp>WechselStatus (line 387)
switch GewichtungNutzer
Error in RL_Bsp>togglebutton1_Callback (line 151)
WechselStatus(Status, Aktion, ButtonWert);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in RL_Bsp (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>#(hObject,eventdata)RL_Bsp('togglebutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
The funny part is that i changed nothing, after i restarted my pc earlier it just started to happen where it used to work 10h ago!
The errors seem to be here:
function WechselStatus(Status, Aktion, ButtonWert)
GewichtungNutzer = getappdata(0,'Wert');
global R_Alg
global Ziel
switch GewichtungNutzer
case {'100'}
GewichtungNutzer = 100;
case {'200'}
GewichtungNutzer = 200;
case {'300'}
GewichtungNutzer = 300;
case {'Ziel mit 500'}
GewichtungNutzer = 0;
otherwise
GewichtungNutzer = -1;
end
if get(ButtonWert,'value') == 1
set(ButtonWert,'Backgroundcolor','0.76, 0.87, 0.78');
if GewichtungNutzer > 0
R_Alg( R_Alg(:,Aktion)==0, Aktion ) = GewichtungNutzer;
else
R_Alg( R_Alg(:,Aktion)==0, Aktion ) = 500;
Ziel = Aktion;
end
elseif get(ButtonWert,'value') == 0
set(ButtonWert,'Backgroundcolor','0.11, 0.31, 0.21');
R_Alg(:, Aktion) = -1;
end
and here
function togglebutton1_Callback(hObject, eventdata, handles)
Status = 1;
Aktion = 1;
ButtonWert = hObject;
WechselStatus(Status, Aktion, ButtonWert);
i got really no clue why i get the error now i was reading many times its something to do with the path that the code can't read the gui? would appreciate help !!
This line:
GewichtungNutzer = getappdata(0,'Wert');
is using the function getappdata to retrieve the value 'Wert' that has been stored in the graphics object 0. Graphics handle 0 always refers to the root object. In order for this line to function as intended, that value must be added to the root object first using setappdata. If it hasn't been initialized, it will return [], which will give you the error you're seeing when you try to use [] in a switch statement.
I'm guessing that, when you had previously run the code, the value of 'Wert' had been set on the root object and everything ran fine. When you reran the code later, this value was, for whatever reason, not set on the root object. Either this value is set on the root object by some other piece of code that you have to run first, or there is a place in your code where the value is only set under certain conditions that were not met the second time you ran it.

Undefined function or variable "Vk" when using sysic to create an interconnected system

I am attempting to use sysic to create an interconnected system from a number of state space models. However; I keep recieving the same error:
Undefined function or variable "Vk".
Error in sysic (line 212)
[ard,arl,er] = LOCALpass1(Vk);
Error in addOutputWeights (line 62)
sysic
The code used that generates this error is as follows:
systemnames = 'plantModel WControl WError';
inputvar = '[r(4); u(4)]';
outputvar = '[WControl; WError;r- plantModel]';
input_to_WError = '[r-plantModel]';
input_to_WControl = '[u]';
sysoutname = 'instramentedPlant';
cleanupsysic= 'yes';
sysic
This error was caused because input_to_plantModel was not present in the workspace. For every system that is refered to in systemnames there must be a corresponding input_to_X.
The following code runs correctly
systemnames='plantModel wControl wError';
inputvar ='[r(4); u(4)]';
outputvar ='[wControl;wError;r- plantModel]';
input_to_plantModel ='[u]';
input_to_wError ='[r-plantModel]';
input_to_wControl ='[u]';
sysoutname ='instramentedPlant';
cleanupsysic = 'yes';

matlab fails deployment in internal code

I want to compile a gui matlab project, but fail because of this error which is not in my code
Subscript indices must either be real positive integers or logicals.
Error in isscript (line 7)
if strcmpi(pth(end-1:end), '.m') && exist(pth, 'file') == 2
Error in matlab.depfun.internal.Schema/move/#(setMembers)setMembers(~isscript(setMembers))
Error in matlab.depfun.internal.Schema>applyMoveFcn (line 987)
keptFiles = fcn(fileList);
Error in matlab.depfun.internal.Schema>#(files,destMap)applyMoveFcn(op,files,destMap,destSet,reason,rule) (line 822)
#(files, destMap)applyMoveFcn(op, files, destMap, ...
Error in matlab.depfun.internal.Schema/applySetRules (line 141)
xformedSet = feval(operations{n}, xformedSet, rMap);
Error in matlab.depfun.internal.Completion/applySetRules (line 1059)
[modifiedList, rMap] = ...
Error in matlab.depfun.internal.Completion/initializeRootSet (line 1142)
[addedFiles, ruleFilter, notes] = ...
Error in matlab.depfun.internal.Completion (line 1601)
obj.RootSet = initializeRootSet(obj, files);
Error in matlab.depfun.internal.requirements (line 166)
c = matlab.depfun.internal.Completion(files, tgt);
Error in appcreate.internal.appbuilder.getDependencyList (line 173)
[dependentfiles, depproducts, ~] = matlab.depfun.internal.requirements(varargin, 'MATLAB');
How can I get matlab (2013b) to compile the package?
The code where matlab fails is (which is NOT my code)
function tf = isscript(files)
% ISSCRIPT Is the file a script file?
tf = false(1,numel(files));
for k=1:numel(files)
pth = files{k};
% Can't be a script if it isn't an M-file.
if strcmpi(pth(end-1:end), '.m') && exist(pth, 'file') == 2
mt = matlab.depfun.internal.cacheMtree(pth);
fcn = mtfind(mt, 'Kind', 'FUNCTION');
tf(k) = isempty(fcn);
end
end
The code will fail for files with a filename of length 1. Either rename all files with such a short filename or change the line to:
if length(pth)>1 && strcmpi(pth(end-1:end), '.m') && exist(pth, 'file') == 2