Labelling graphs/images with text() function

  • Thread starter Thread starter nyxynyx
  • Start date Start date
  • Tags Tags
    Function Text
Click For Summary
SUMMARY

The forum discussion centers on labeling circles in a 20x20 arrangement using the MATLAB text() function. The initial attempt to label the circles with running numbers from 1 to 400 failed because the text() function requires string inputs. The solution provided involves converting the numbers to strings using the num2str() function, which successfully resolves the issue.

PREREQUISITES
  • Familiarity with MATLAB programming language
  • Understanding of the text() function in MATLAB
  • Knowledge of the num2str() function for string conversion
  • Basic skills in plotting and graphical representation in MATLAB
NEXT STEPS
  • Explore advanced MATLAB plotting techniques
  • Learn about other string manipulation functions in MATLAB
  • Investigate graphical annotations in MATLAB for enhanced visualizations
  • Study MATLAB's for loop and its applications in data visualization
USEFUL FOR

This discussion is beneficial for MATLAB users, data visualization specialists, and anyone involved in graphical programming who needs to label plots 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 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
Replies
4
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K