SPRINTF and FPRINTF are repeating formatSpec as many times as needed to display the content of the arguments that follow. To illustrate:
>> fprintf('Value = %d\n', [1, 2, 3])
Value = 1
Value = 2
Value = 3
so it's not always obvious how to pass multiple arrays and obtain an output which corresponds to what we want (in your case, you would have to concatenate all the arrays I guess and pass them column by column instead of row by row) .. however, you could go for a loop here:
formatSpec = 'The slope of a line containing points(%i, %i) and (%i, %i) is %8.4f\n' ;
for k = 1 : numel(aX1)
fprintf(formatSpec, aX1(k), aY1(k), aX2(k), aY2(k), m1(k)) ;
end
Best Answer