Writing data on a blank figure
Mostrar comentarios más antiguos
I want to generate a blank figure/image and write a text and variable value using a for loop. For example, writing X:y where X is just a text (which does not change) but value of y is written from a variable and it keeps changing with each iteration. I tried using 'text' but have not got the output i want.
Thanks.
Respuestas (2)
Walter Roberson
el 6 de Mzo. de 2018
1 voto
text() does that for display purposes. But if you are aiming for an image you would have to capture the axes content with getframe() or saveas() or print() to use text()
If you need an image then the alternative is to use the Computer Vision Toolbox with its insertShape and insertText functions.
6 comentarios
Walter Roberson
el 6 de Mzo. de 2018
You have to assign the result of insertText to hf.
HT
el 6 de Mzo. de 2018
Walter Roberson
el 6 de Mzo. de 2018
hf = insertText(hf, [0.5 0.5], ['X =', text_str(i)], ....)
or if text_str(i) is numeric, sprintf() up something
sprintf('X = %g', text_str(i))
HT
el 8 de Mzo. de 2018
Walter Roberson
el 8 de Mzo. de 2018
Editada: Walter Roberson
el 8 de Mzo. de 2018
Is it possible that text_str is a cell array rather than a character vector or string object ? If so then you would need text_str{7} rather than text_str(7)
This presumes that if text_str is a cell, that text_str{7} only contains a single row of text.
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!