Fonction MATLAB qui imprime presque toutes les entrées
La fonction MATLAB suivante peut être utilisée pour imprimer chaque entrée en utilisant fprintf, indépendamment de son type. Puisqu’elle n’utilise pas mat2str(), elle peut également être utilisée dans la génération de code MATLAB Coder.
printit.m
function printit(inputValue)
if isnumeric(inputValue) || islogical(inputValue)
% Imprimer les tableaux numériques/logiques élément par élément
fprintf('Input: %g \n', inputValue(:));
elseif ischar(inputValue)
fprintf('Input: %s\n', inputValue);
elseif isstring(inputValue)
fprintf('Input: %s\n', char(inputValue));
elseif iscell(inputValue)
disp('Input (cell):');
disp(inputValue);
elseif isstruct(inputValue)
disp('Input (struct):');
disp(inputValue);
else
disp('Input (unknown type):');
disp(inputValue);
end
endConsultez les articles similaires par catégorie :
Matlab/Simulink
Si cet article vous a aidé, pensez à m'offrir un café ou à faire un don via PayPal pour soutenir la recherche et la publication de nouveaux articles sur TechOverflow