How do I parse two input arguments for matching dimensions with Matlab Input Parser?
Mostra commenti meno recenti
I use the Matlab Inputparser Class to validate function input, this is a minimal example:
function C = multiplyMatrix(A, B)
p = inputParser;
addRequired(p, 'A', @isnumeric); % Line A
addRequired(p, 'B', @isnumeric);
parse(p, A, B);
if size(A, 2) ~= size(B, 1) % Line B
error('Size mismatch.');
end
C = A*B;
end
How do I integrate tests spanning more than one variable (i.e. the if-statement in Line B) in the concept of the Matlab Inputparser Class? I only found out how to create tests regarding one variable (see Line A).
I am also happy about comments about the usage of this Parser in total.
(I had asked this question on stackoverflow.com before, but I feel like this is the better place to ask.)
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Argument Definitions in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!