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]);

Respuestas (2)

per isakson
per isakson el 20 de Jul. de 2012

0 votos

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 el 20 de Jul. de 2012

0 votos

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

Categorías

Más información sobre Text Analytics Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 20 de Jul. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by