如何在MATLAB中获得多行控制台输出?使用horzcat给我一个错误

Nul*_*uli 3 matlab

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

但后来我得到了错误:

??? 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',...
Run Code Online (Sandbox Code Playgroud)

gno*_*ice 5

您似乎]将格式字符串的右括号放在错误的位置.试试这个:

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
Run Code Online (Sandbox Code Playgroud)