Text output keeps repeating

3 vues (au cours des 30 derniers jours)
Jaden
Jaden le 20 Juil 2012
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]);

Réponses (2)

per isakson
per isakson le 20 Juil 2012
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 le 20 Juil 2012
text() will produce multiple copies of the output string if it is given non-scalar positions.

Catégories

En savoir plus sur Text Analytics Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by