Text output keeps repeating

Hi! I'm getting a strange result -- my text overlay for my graph is repeating itself. It used to work fine and I didn't change any of that specific code, so I'm not sure why the change happened. In addition, while trying to debug, I wrote a simpler overlay and was able to see that the overlay repeats infinitely.
The code for the text overlay is below, as well as a picture of the problem.
Picture (no error):
Picture (current error):
Code:
xlabel('Distance to the right/left of the center of the laser scanner in meters.');
ylabel('Distance in front of the laser scanner in meters.');
titleFrame = sprintf('ICP, overhead view. Scan # = %d', numberOfScans);
title(titleFrame);
output = sprintf('Angle: %f degrees. \nTotal Distance: %f m. \nRight Encoder Distance: %f m. \nLeft Encoder Distance: %f m.\nAverage Velocity: %f m/s. \nAcceleration: %f m/s^2.\n', robotAngle, robotMovement, rightEncoderTotal, leftEncoderTotal, robotVel, robotAcc);
text(xText, yText, output, 'BackgroundColor',[1 1 1], 'EdgeColor', [0 0 0]);

回答(2 个)

When debugging did you inspect the value of output? The code you show can hardly give multiple groups of lines. The values of robotAngle, robotMovement, etc. are they scalars?
>> sprintf( 'A: %f\nB: %f\n', [1;2], [3;4] )
ans =
A: 1.000000
B: 2.000000
A: 3.000000
B: 4.000000
Walter Roberson
Walter Roberson 2012-7-20

0 个投票

text() will produce multiple copies of the output string if it is given non-scalar positions.

类别

帮助中心File Exchange 中查找有关 Text Analytics Toolbox 的更多信息

提问:

2012-7-20

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by