mex file and gpib link
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone.
I have the following question. I adjust some device via gpib-connection. In main m-file I write:
glink=gpib('ni', 0 , 1);
Can I call my mex-file with glink parameter: myMex(glink)? I mean, there is a string somewhere in mex-file:
fopen(glink);
fprintf(glink, '*IDN?');
fscanf(glink);
fclose(glink);
And how can I check glink is an object? Does the 'mxIsObject' exist?
0 commentaires
Réponses (2)
James Tursa
le 11 Juin 2014
To examine what the class name is for a variable in a mex routine you can use mxGetClassName:
E.g.,
char *classname;
classname = mxGetClassName(prhs[0]);
Then you can test classname against any particular string (e.g., "glink") to see if it is an object of that class.
0 commentaires
Dekun Pei
le 16 Juin 2014
In addition to what James said, I would be careful with using "fopen", "fprintf", "fscanf" and "fclose" in your mex file. These functions in MATLAB are overloaded to support instrument objects. However, this is NOT the case in mex file as the C/C++ version of these function will be used and they are most definitely not set up to handle MATLAB objects.
If you must use them on glink in a C/C++ mex file, call them through "mexCallMATLAB" (<http://www.mathworks.com/help/matlab/apiref/mexcallmatlab.html)>, which essentially calls these function in MATLAB.
0 commentaires
Voir également
Catégories
En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!