Labelling graphs/images with text() function

  • Thread starter Thread starter nyxynyx
  • Start date Start date
  • Tags Tags
    Function Text
AI Thread Summary
The discussion revolves around a user attempting to label circles in a 20x20 arrangement with numbers from 1 to 400 using a coding approach. The initial code provided does not function as intended because it attempts to label with numbers directly. A solution is suggested to convert the numbers to strings using the num2str function, which resolves the issue. The user confirms that this solution works effectively.
nyxynyx
Messages
34
Reaction score
0
Hi, I'm plotting some circles in a 20x20 arrangement using the rectangle tool and I have to label each of the circle a number from 1 to 400. However, the following code does not do what i once, since i think i can only label with strings and not running numbers...

Code:
for i=1:400
    text(x_pos(i),y_pos(i),i)
end

What else can i try? Thanks!
 
Physics news on Phys.org
You could just convert the number to a string using the num2str function.
Look it up in the help.
 
thnx f95toli this works!
 

Similar threads

Replies
3
Views
2K
Replies
5
Views
4K
Replies
2
Views
2K
Replies
2
Views
5K
Replies
0
Views
323
Replies
2
Views
2K
Back
Top