How to get multi-line console output in MATLAB? Using horzcat gives me an error

fprintf(['# True Positive: %d \n',...
            '# False Positive: %d \n',...
            '# True Negative: %d \n',...
            '# False Negative: %d \n,',...
            numTruePos,...
            numFalsePos,...
            numTrueNeg,...
            numFalseNeg]);

but then I get the error:

??? Error using ==> horzcat
The following error occurred converting from logical to
char:
Error using ==> char
Conversion to char from logical is not possible.

Error in ==> toyProblem at 40
fprintf(['# True Positive: %d \n',...
+3
source share
1 answer

You have a closing bracket ]for the format string in the wrong place. Try the following:

fprintf(['# True Positive: %d \n',...
         '# False Positive: %d \n',...
         '# True Negative: %d \n',...
         '# False Negative: %d \n'],...  %# Moved it to here...
         numTruePos,...
         numFalsePos,...
         numTrueNeg,...
         numFalseNeg);  %# ... from here
+5
source

Source: https://habr.com/ru/post/1784655/


All Articles