How do I check if an input argument is empty in a MEX file in MATLAB 7.10 (R2010a)?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 2 Jun. 2010
Bearbeitet: James Tursa
am 5 Feb. 2021
I would like to check if an input argument is empty in a MEX file. This is similar to using the ISEMPTY function in MATLAB.
Akzeptierte Antwort
MathWorks Support Team
am 2 Jun. 2010
The following command can be used to check if an argument is empty by checking if the dimension is zero.
if (mxGetM(prhs[i]) == 0 && mxGetN(prhs[i]) == 0)
mexErrMsgTxt("Empty argument.");
1 Kommentar
James Tursa
am 5 Feb. 2021
Bearbeitet: James Tursa
am 5 Feb. 2021
From the mxGetN documentation:
If pm is an N-dimensional mxArray, mxGetN is the product of dimensions 2 through N.
So, the above answer is not wrong for the usage of mxGetN( ). However, it is wrong as you point out for the usage of && ... it should be || instead.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Call C++ from MATLAB finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!